> For the complete documentation index, see [llms.txt](https://docs.yifi.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.yifi.io/docs/earn/markets.md).

# Markets

Unified DeFi markets – Staking/LST, DEX, Lending, Fixed Income, Structured Vaults, Stablecoins

## List markets

> Get paginated markets with filters.

```json
{"openapi":"3.1.1","info":{"title":"YiFi Yield Aggregator – Data Gateway API","version":"v1"},"tags":[{"description":"Unified DeFi markets – Staking/LST, DEX, Lending, Fixed Income, Structured Vaults, Stablecoins","name":"Markets"}],"servers":[{"url":"https://core-dev.yifi.io/api/v1"}],"security":[{"BearerToken":[]},{"PartnerApiKey":[]}],"components":{"securitySchemes":{"BearerToken":{"description":"Admin key for privileged operations (create/edit/delete).","type":"apiKey","name":"Authorization","in":"header"},"PartnerApiKey":{"description":"Partner API key used for B2B attribution (wallets, platforms). Requests authenticated with this key are attributed to the owning partner.","type":"apiKey","name":"X-Partner-Api-Key","in":"header"}},"schemas":{"rest.Response":{"type":"object","properties":{"code":{"type":"string"},"data":{},"isError":{"type":"boolean"},"message":{"type":"string"},"success":{"type":"boolean"}}},"common.Pagination-core_MarketsResponse":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/core.MarketsResponse"}},"page":{"$ref":"#/components/schemas/common.Page"}}},"core.MarketsResponse":{"type":"object","properties":{"annual_rate":{"description":"out of meta for effective search","type":"string"},"category":{"type":"string"},"chain":{"type":"string"},"market_id":{"type":"string"},"name":{"type":"string"},"participating_tokens":{"description":"slice of tokenIDs // no need for more for creating a market","type":"array","items":{"$ref":"#/components/schemas/common.TokenAddress"}},"platform":{"type":"string"},"rate_format":{"type":"string"},"tvl_usd":{"description":"in usd","type":"string"},"yield_type":{"description":"user inserts","type":"string"}}},"common.TokenAddress":{"type":"object","properties":{"address":{"type":"string"},"chain":{"type":"string"},"decimals":{"type":"integer"},"logo_url":{"description":"new","type":"string"},"price_usd":{"type":"string"},"role":{"type":"string"},"symbol":{"type":"string"},"token_id":{"type":"string"}}},"common.Page":{"type":"object","properties":{"currentPage":{"description":"page-based pagination","type":"integer"},"id":{"description":"keyset-based pagination","type":"string"},"limit":{"description":"common","type":"integer"},"nextCursor":{"type":"string"},"offset":{"description":"offset-based pagination","type":"integer"},"pageSize":{"type":"integer"},"prevCursor":{"description":"cursor-based pagination","type":"string"},"totalItems":{"type":"integer"},"totalPages":{"type":"integer"},"type":{"type":"string"}}},"core.Msg":{"type":"object","properties":{"message":{"type":"string"}}}}},"paths":{"/markets":{"get":{"description":"Get paginated markets with filters.","tags":["Markets"],"summary":"List markets","parameters":[{"schema":{"type":"string"},"description":"search","name":"search","in":"query"},{"schema":{"type":"string"},"description":"market ids","name":"ids","in":"query"},{"schema":{"type":"string"},"description":"comma separated category ids","name":"categoryIds","in":"query"},{"schema":{"type":"string"},"description":"comma separated platform ids","name":"platformIds","in":"query"},{"schema":{"type":"string"},"description":"comma separated chain ids","name":"chainIds","in":"query"},{"schema":{"type":"string"},"description":"comma separated token ids","name":"tokenIds","in":"query"},{"schema":{"type":"string"},"description":"min tvl usd","name":"minTvlUsd","in":"query"},{"schema":{"type":"string"},"description":"max tvl usd","name":"maxTvlUsd","in":"query"},{"schema":{"type":"string"},"description":"min apr","name":"minApr","in":"query"},{"schema":{"type":"string"},"description":"max apr","name":"maxApr","in":"query"},{"schema":{"type":"string"},"description":"sort field by tvlUsd | apr | apy | createdAt | updatedAt","name":"sortBy","in":"query"},{"schema":{"type":"string"},"description":"asc | desc","name":"sortDirection","in":"query"},{"schema":{"type":"integer"},"description":"limit","name":"limit","in":"query"},{"schema":{"type":"integer"},"description":"offset","name":"offset","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/rest.Response"},{"type":"object","properties":{"data":{"$ref":"#/components/schemas/common.Pagination-core_MarketsResponse"}}}]}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/core.Msg"}}}}}}}}}
```

## Get market

> Get market by id.

```json
{"openapi":"3.1.1","info":{"title":"YiFi Yield Aggregator – Data Gateway API","version":"v1"},"tags":[{"description":"Unified DeFi markets – Staking/LST, DEX, Lending, Fixed Income, Structured Vaults, Stablecoins","name":"Markets"}],"servers":[{"url":"https://core-dev.yifi.io/api/v1"}],"security":[{"BearerToken":[]},{"PartnerApiKey":[]}],"components":{"securitySchemes":{"BearerToken":{"description":"Admin key for privileged operations (create/edit/delete).","type":"apiKey","name":"Authorization","in":"header"},"PartnerApiKey":{"description":"Partner API key used for B2B attribution (wallets, platforms). Requests authenticated with this key are attributed to the owning partner.","type":"apiKey","name":"X-Partner-Api-Key","in":"header"}},"schemas":{"rest.Response":{"type":"object","properties":{"code":{"type":"string"},"data":{},"isError":{"type":"boolean"},"message":{"type":"string"},"success":{"type":"boolean"}}},"core.MarketCurrentResponse":{"type":"object","properties":{"annual_rate":{"description":"out of meta for effective search","type":"string"},"category":{"type":"string"},"chain":{"type":"string"},"market_id":{"type":"string"},"meta":{},"name":{"type":"string"},"participating_tokens":{"description":"slice of tokenIDs // no need for more for creating a market","type":"array","items":{"$ref":"#/components/schemas/common.TokenAddress"}},"platform":{"type":"string"},"rate_format":{"type":"string"},"tvl_usd":{"description":"in usd","type":"string"},"yield_type":{"description":"user inserts","type":"string"}}},"common.TokenAddress":{"type":"object","properties":{"address":{"type":"string"},"chain":{"type":"string"},"decimals":{"type":"integer"},"logo_url":{"description":"new","type":"string"},"price_usd":{"type":"string"},"role":{"type":"string"},"symbol":{"type":"string"},"token_id":{"type":"string"}}},"core.Msg":{"type":"object","properties":{"message":{"type":"string"}}}}},"paths":{"/markets/{market_id}":{"get":{"description":"Get market by id.","tags":["Markets"],"summary":"Get market","parameters":[{"schema":{"type":"string"},"description":"market id","name":"market_id","in":"path","required":true}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/rest.Response"},{"type":"object","properties":{"data":{"$ref":"#/components/schemas/core.MarketCurrentResponse"}}}]}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/core.Msg"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/core.Msg"}}}}}}}}}
```

## Market history metrics

> Get market historical metrics for a given period.

```json
{"openapi":"3.1.1","info":{"title":"YiFi Yield Aggregator – Data Gateway API","version":"v1"},"tags":[{"description":"Unified DeFi markets – Staking/LST, DEX, Lending, Fixed Income, Structured Vaults, Stablecoins","name":"Markets"}],"servers":[{"url":"https://core-dev.yifi.io/api/v1"}],"security":[{"BearerToken":[]},{"PartnerApiKey":[]}],"components":{"securitySchemes":{"BearerToken":{"description":"Admin key for privileged operations (create/edit/delete).","type":"apiKey","name":"Authorization","in":"header"},"PartnerApiKey":{"description":"Partner API key used for B2B attribution (wallets, platforms). Requests authenticated with this key are attributed to the owning partner.","type":"apiKey","name":"X-Partner-Api-Key","in":"header"}},"schemas":{"rest.Response":{"type":"object","properties":{"code":{"type":"string"},"data":{},"isError":{"type":"boolean"},"message":{"type":"string"},"success":{"type":"boolean"}}},"core.MarketHistoryResponse":{"type":"object","properties":{"history":{"description":"category specific history metrics","type":"array","items":{"$ref":"#/components/schemas/core.History"}},"market_id":{"description":"key in portals","type":"string"},"rate_format":{"type":"string"},"yield_type":{"description":"admin inserts","type":"string"}}},"core.History":{"type":"object","properties":{"annual_rate":{"description":"out of meta for effective search. NEED ONLY FOR SEARCH. NOT OUTPUT. META ALREADY CONTAINS ALL INFO","type":"string"},"timestamp":{"description":"Meta      common.Meta `json:\"meta\"` // временно забиваем","type":"string"},"tvl_usd":{"description":"in usd","type":"string"}}},"core.Msg":{"type":"object","properties":{"message":{"type":"string"}}}}},"paths":{"/markets/{market_id}/metrics":{"get":{"description":"Get market historical metrics for a given period.","tags":["Markets"],"summary":"Market history metrics","parameters":[{"schema":{"type":"string"},"description":"market id","name":"market_id","in":"path","required":true},{"schema":{"type":"string"},"description":"start time RFC3339","name":"from","in":"query"},{"schema":{"type":"string"},"description":"end time RFC3339","name":"to","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/rest.Response"},{"type":"object","properties":{"data":{"$ref":"#/components/schemas/core.MarketHistoryResponse"}}}]}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/core.Msg"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/core.Msg"}}}}}}}}}
```

## Market token roles

> List roles tokens can play in markets.

```json
{"openapi":"3.1.1","info":{"title":"YiFi Yield Aggregator – Data Gateway API","version":"v1"},"tags":[{"description":"Unified DeFi markets – Staking/LST, DEX, Lending, Fixed Income, Structured Vaults, Stablecoins","name":"Markets"}],"servers":[{"url":"https://core-dev.yifi.io/api/v1"}],"security":[{"BearerToken":[]},{"PartnerApiKey":[]}],"components":{"securitySchemes":{"BearerToken":{"description":"Admin key for privileged operations (create/edit/delete).","type":"apiKey","name":"Authorization","in":"header"},"PartnerApiKey":{"description":"Partner API key used for B2B attribution (wallets, platforms). Requests authenticated with this key are attributed to the owning partner.","type":"apiKey","name":"X-Partner-Api-Key","in":"header"}},"schemas":{"rest.Response":{"type":"object","properties":{"code":{"type":"string"},"data":{},"isError":{"type":"boolean"},"message":{"type":"string"},"success":{"type":"boolean"}}},"core.Msg":{"type":"object","properties":{"message":{"type":"string"}}}}},"paths":{"/roles":{"get":{"description":"List roles tokens can play in markets.","tags":["Markets"],"summary":"Market token roles","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/rest.Response"},{"type":"object","properties":{"data":{"type":"array","items":{"type":"string"}}}}]}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/core.Msg"}}}}}}}}}
```
