### Usage examples for GeckoTerminalAPI constructor Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/sync-client.md Shows how to instantiate the GeckoTerminalAPI client. The first example creates a client with default settings. The second example passes an explicit API version and proxies dictionary, which sets the Accept header to 'application/json;version=2023-12-19' and assigns the proxies to the session. ```python from geckoterminal_api import GeckoTerminalAPI gt = GeckoTerminalAPI() # with an explicit API version and proxies gt = GeckoTerminalAPI( api_version="2023-12-19", proxies={"http": "http://10.10.10.10:8000", "https": "http://10.10.10.10:8000"}, ) ``` -------------------------------- ### Install geckoterminal-api Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/README.md Install the geckoterminal-api package from PyPI. ```bash pip install geckoterminal-api ``` -------------------------------- ### network_addresses_token_price: Get token prices Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/async-client-data.md Shows the method signature and a usage example for fetching current USD prices of multiple tokens on a network. The addresses are joined with "," into the URL path, and a warning is issued if the list length exceeds 30. ```python @validate(max_addresses=MAX_ADDRESSES) async def network_addresses_token_price( self, network: str, addresses: list[str] ) -> dict: """Get current USD prices of multiple tokens on a network""" ``` ```python async def main() -> None: agt = AsyncGeckoTerminalAPI() prices = await agt.network_addresses_token_price( network="eth", addresses=[ "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", ], ) print(prices["data"]["attributes"]["token_prices"]) await agt.close() ``` -------------------------------- ### Usage example for network_pools Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/async-client.md Example of using `network_pools` to get pools on the Arbitrum network with page 2. It prints the number of pools returned and closes the client connection. ```python async def main() -> None: agt = AsyncGeckoTerminalAPI() pools = await agt.network_pools(network="arbitrum", page=2) print(len(pools["data"])) await agt.close() ``` -------------------------------- ### network_token_pools: Get top pools for a token Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/async-client-data.md Shows the method signature and a usage example for getting top pools for a token on a network. The include parameter defaults to NETWORK_POOL_INCLUDES and is validated against it; a warning is issued if page is greater than 10. ```python @validate(max_page=MAX_PAGE, include_list=NETWORK_POOL_INCLUDES) async def network_token_pools( self, network: str, token_address: str, include: list | None = None, page: int = 1, ) -> dict: """Get top pools for a token on a network""" ``` ```python async def main() -> None: agt = AsyncGeckoTerminalAPI() pools = await agt.network_token_pools( network="eth", token_address="0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48" ) print(len(pools["data"])) await agt.close() ``` -------------------------------- ### search_network_pool usage example Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/async-client-data.md Example of searching for a pool with query 'USDC' on network 'eth' and printing pool names. Requires closing the client with await agt.close(). ```python async def main() -> None: agt = AsyncGeckoTerminalAPI() results = await agt.search_network_pool(query="USDC", network="eth") print([p["attributes"]["name"] for p in results["data"]]) await agt.close() ``` -------------------------------- ### network_pool_info: Get pool tokens info Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/async-client-data.md Method signature and usage example for `network_pool_info`. The method is not decorated with `@validate`. The example calls it with `network="eth"` and a pool address, then prints the `data.attributes` from the response. ```python async def network_pool_info(self, network: str, pool_address: str) -> dict: """Get pool tokens info on a network""" ``` ```python async def main() -> None: agt = AsyncGeckoTerminalAPI() info = await agt.network_pool_info( network="eth", pool_address="0x60594a405d53811d3bc4766596efd80fd545a270" ) print(info["data"]["attributes"]) await agt.close() ``` -------------------------------- ### network_dexes usage example Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/async-client.md Example of using network_dexes to fetch DEXes on the solana network and print their IDs. Requires an AsyncGeckoTerminalAPI instance and closes it after use. ```python async def main() -> None: agt = AsyncGeckoTerminalAPI() dexes = await agt.network_dexes(network="solana") print([d["id"] for d in dexes["data"]]) await agt.close() ``` -------------------------------- ### network_dexes usage example Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/sync-client.md Example call to `network_dexes` for the `eth` network, printing the first five DEX IDs from the response data. ```python dexes = gt.network_dexes(network="eth") print([d["id"] for d in dexes["data"]][:5]) # e.g. ['uniswap_v2', 'sushiswap', ...] ``` -------------------------------- ### trending_pools usage example Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/sync-client.md Example call to `trending_pools` with default parameters, printing the name and 24-hour volume of the first trending pool. ```python trending = gt.trending_pools() pool = trending["data"][0]["attributes"] print(pool["name"], pool["volume_usd"]["h24"]) ``` -------------------------------- ### network_tokens_address_info: Get token address info Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/async-client-data.md Method signature and usage example for `network_tokens_address_info`. The method is not decorated with `@validate`. The example calls it with `network="eth"` and a token address, then prints the `data.attributes` from the response. ```python async def network_tokens_address_info(self, network: str, address: str) -> dict: """Get token address info on a network""" ``` ```python async def main() -> None: agt = AsyncGeckoTerminalAPI() info = await agt.network_tokens_address_info( network="eth", address="0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2" ) print(info["data"]["attributes"]) await agt.close() ``` -------------------------------- ### Synchronous API example Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/README.md Initialize the synchronous GeckoTerminalAPI client and fetch supported networks and their IDs. ```python from geckoterminal_api import GeckoTerminalAPI gt = GeckoTerminalAPI() # Fetch supported networks and their IDs gt.networks() ``` -------------------------------- ### network_pool_address method and usage Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/async-client.md Shows the method signature for network_pool_address and two usage examples. The first example retrieves a pool by its address and prints the pool name. The second example demonstrates error handling by catching GeckoTerminalAPIError when an invalid address is used. ```python @validate(include_list=NETWORK_POOL_INCLUDES) async def network_pool_address( self, network: str, address: str, include: list | None = None, ) -> dict: """Get specific pool on a network""" ``` ```python async def main() -> None: agt = AsyncGeckoTerminalAPI() pool = await agt.network_pool_address( network="eth", address="0x60594a405d53811d3bc4766596efd80fd545a270" ) print(pool["data"]["attributes"]["name"]) await agt.close() ``` ```python async def main() -> None: agt = AsyncGeckoTerminalAPI() try: await agt.network_pool_address(network="eth", address="0xdeadbeef") except GeckoTerminalAPIError as exc: print(str(exc)) await agt.close() ``` -------------------------------- ### Example usage of network_pool_trades Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/async-client-data.md Example usage of the network_pool_trades method. It creates an AsyncGeckoTerminalAPI instance, fetches trades for a Solana pool, prints the first five trades' block timestamp, kind, and volume in USD, then closes the client. ```python async def main() -> None: agt = AsyncGeckoTerminalAPI() trades = await agt.network_pool_trades( network="solana", pool_address="69grLw4PcSypZnn3xpsozCJFT8vs8WA5817VUVnzNGTh" ) for trade in trades["data"][:5]: attrs = trade["attributes"] print(attrs["block_timestamp"], attrs["kind"], attrs["volume_in_usd"]) await agt.close() ``` -------------------------------- ### search_network_pool error handling example Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/async-client-data.md Example of catching GeckoTerminalAPIError when searching for a non-existent token. Prints the error status and message. ```python async def main() -> None: agt = AsyncGeckoTerminalAPI() try: await agt.search_network_pool(query="not a real token") except GeckoTerminalAPIError as exc: print(exc.status, exc.err) await agt.close() ``` -------------------------------- ### Usage example for network_pools_multi_address Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/async-client.md Example of using `network_pools_multi_address` with two Ethereum pool addresses. It prints the number of pools returned and closes the client connection. ```python async def main() -> None: agt = AsyncGeckoTerminalAPI() pools = await agt.network_pools_multi_address( network="eth", addresses=[ "0x60594a405d53811d3bc4766596efd80fd545a270", "0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640", ], ) print(len(pools["data"])) await agt.close() ``` -------------------------------- ### network_token method and usage Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/async-client-data.md Shows the network_token method definition and a usage example. The method is decorated with @validate(include_list=TOKEN_INCLUDES) and returns a dict. The example creates an AsyncGeckoTerminalAPI instance, calls network_token with network="eth" and a token address, prints the token symbol, and closes the client. ```python @validate(include_list=TOKEN_INCLUDES) async def network_token( self, network: str, address: str, include: list | None = None ) -> dict: """Get specific token on a network""" ``` ```python async def main() -> None: agt = AsyncGeckoTerminalAPI() token = await agt.network_token( network="eth", address="0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48" ) print(token["data"]["attributes"]["symbol"]) await agt.close() ``` -------------------------------- ### trending_pools usage example Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/async-client.md Example of using trending_pools to fetch trending pools and print the name of the first pool. Requires an AsyncGeckoTerminalAPI instance and closes it after use. ```python async def main() -> None: agt = AsyncGeckoTerminalAPI() trending = await agt.trending_pools() print(trending["data"][0]["attributes"]["name"]) await agt.close() ``` -------------------------------- ### close() usage example Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/async-client.md Shows how to call close() on an AsyncGeckoTerminalAPI instance to clean up the session. ```python await agt.close() ``` -------------------------------- ### network_tokens_multi_address method and usage Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/async-client-data.md Shows the network_tokens_multi_address method definition and a usage example. The method is decorated with @validate(max_addresses=MAX_ADDRESSES, include_list=TOKEN_INCLUDES) and returns a dict. The example creates an AsyncGeckoTerminalAPI instance, calls network_tokens_multi_address with network="eth" and a list of two token addresses, prints the symbols of the returned tokens, and closes the client. ```python @validate(max_addresses=MAX_ADDRESSES, include_list=TOKEN_INCLUDES) async def network_tokens_multi_address( self, network: str, addresses: list[str], include: list | None = None ) -> dict: """Get multiple tokens on a network""" ``` ```python async def main() -> None: agt = AsyncGeckoTerminalAPI() tokens = await agt.network_tokens_multi_address( network="eth", addresses=[ "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", ], ) print([t["attributes"]["symbol"] for t in tokens["data"]]) await agt.close() ``` -------------------------------- ### GET /networks Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/endpoints.md Returns a list of all supported networks by GeckoTerminal. ```APIDOC ## GET /networks ### Description Returns a list of all networks supported by GeckoTerminal. ### Method GET ### Endpoint /networks ### Response #### Success Response (200) - **networks** (array) - List of network objects with network details. ``` -------------------------------- ### Call token_info_recently_updated with no arguments Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/sync-client-data.md Example call to token_info_recently_updated with no arguments. Prints the number of items in the 'data' key, which should be 100. ```python updated = gt.token_info_recently_updated() print(len(updated["data"])) # most recently updated 100 tokens ``` -------------------------------- ### GET /networks/{network}/pools/multi/{address1,address2,...} Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/endpoints.md Returns multiple pools by addresses on a network. ```APIDOC ## GET /networks/{network}/pools/multi/{address1,address2,...} ### Description Returns multiple pools by their addresses on a given network. ### Method GET ### Endpoint /networks/{network}/pools/multi/{address1,address2,...} ### Parameters #### Path Parameters - **network** (string) - Required - The network identifier. - **address1,address2,...** (string) - Required - Comma-separated pool addresses. ### Response #### Success Response (200) - **data** (array) - List of pool objects. ``` -------------------------------- ### Asynchronous API example Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/README.md Initialize the asynchronous AsyncGeckoTerminalAPI client and fetch supported networks and their IDs using asyncio.run. ```python import asyncio from geckoterminal_api import AsyncGeckoTerminalAPI agt = AsyncGeckoTerminalAPI() # Fetch supported networks and their IDs asyncio.run(agt.networks()) ``` -------------------------------- ### Constructor Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/async-client.md Initializes the async client with optional API version and proxy. The session is created lazily on the first request. ```APIDOC ## Constructor ### Description Initializes the AsyncGeckoTerminalAPI client with optional API version and proxy settings. The session is created lazily on the first request. ### Signature ```python def __init__( self, api_version: str | None = None, proxy: str | None = None ) -> None: ``` ### Parameters - **api_version** (str | None) - Optional - GeckoTerminal API version. When set, the Accept header becomes `application/json;version={api_version}`; when None, plain `application/json`. - **proxy** (str | None) - Optional - Proxy URL, e.g. `"http://proxy.com"`, passed as `proxy=` to every aiohttp request. ### Instance Attributes - **base_url** (str) - Value: `"https://api.geckoterminal.com/api/v2"` (hardcoded) - **accept_header** (str) - Value: `f"application/json;version={api_version}"` if api_version else `"application/json"` - **proxy** (str | None) - Constructor value - **_session** (None | aiohttp.ClientSession) - `None` until the first `_get` call creates it; set back to `None` by `close()`. ### Example ```python from geckoterminal_api import AsyncGeckoTerminalAPI agt = AsyncGeckoTerminalAPI() # no request happens yet agt = AsyncGeckoTerminalAPI(proxy="http://proxy.com") agt = AsyncGeckoTerminalAPI(api_version="2023-12-19") ``` ``` -------------------------------- ### Instantiate AsyncGeckoTerminalAPI without arguments, with proxy, and with api_version Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/async-client.md Three separate ways to create an AsyncGeckoTerminalAPI instance. No HTTP request is made at construction time; the session is created lazily on the first request. The examples show the default instantiation, passing a proxy URL, and setting an API version string. ```python from geckoterminal_api import AsyncGeckoTerminalAPI agt = AsyncGeckoTerminalAPI() # no request happens yet agt = AsyncGeckoTerminalAPI(proxy="http://proxy.com") agt = AsyncGeckoTerminalAPI(api_version="2023-12-19") ``` -------------------------------- ### Async client usage with proxy Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/configuration.md Usage example for the asynchronous client with a proxy URL. Shows how to instantiate AsyncGeckoTerminalAPI with a proxy string. ```python # Async with proxy (README pattern) from geckoterminal_api import AsyncGeckoTerminalAPI agt = AsyncGeckoTerminalAPI(proxy="http://proxy.com") ``` -------------------------------- ### token_info_recently_updated: Get recently updated tokens Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/async-client-data.md Method signature and usage example for `token_info_recently_updated`. The method is decorated with `@validate` using `MAX_ADDRESSES` and `TOKEN_INFO_INCLUDES`. The example calls it without arguments and prints the number of items in the `data` list. ```python @validate(max_addresses=MAX_ADDRESSES, include_list=TOKEN_INFO_INCLUDES) async def token_info_recently_updated(self, include: list | None = None) -> dict: """Get most recently updated 100 tokens info from all networks""" ``` ```python async def main() -> None: agt = AsyncGeckoTerminalAPI() updated = await agt.token_info_recently_updated() print(len(updated["data"])) await agt.close() ``` -------------------------------- ### Get pool by address on eth Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/sync-client.md Example call to network_pool_address for an Ethereum pool. It retrieves the pool details and prints the pool name. ```python pool = gt.network_pool_address( network="eth", address="0x60594a405d53811d3bc4766596efd80fd545a270" ) print(pool["data"]["attributes"]["name"]) ``` -------------------------------- ### Get trending pools on litecoin with include Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/sync-client.md Example call to network_trending_pools for the litecoin network with a custom include list. It prints the pool ids, which follow the format "_
". ```python ltc = gt.network_trending_pools(network="litecoin", include=["base_token"]) print([p["id"] for p in ltc["data"]]) # pool ids: "_
" ``` -------------------------------- ### Set up asynchronous API proxy Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/README.md Configure a proxy for the asynchronous AsyncGeckoTerminalAPI client by passing a proxy string to the constructor. ```python from geckoterminal_api import AsyncGeckoTerminalAPI proxy = "http://proxy.com" agt = AsyncGeckoTerminalAPI(proxy=proxy) ``` -------------------------------- ### network_new_pools: Get new pools on a network Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/async-client.md Retrieves new pools on a network. The method signature shows the `@validate` decorator with `MAX_PAGE` and `NETWORK_POOL_INCLUDES`. The example calls `network_new_pools` with an invalid network `"arb"`, catches `GeckoTerminalAPIError`, and prints the status code `404`. ```python @validate(max_page=MAX_PAGE, include_list=NETWORK_POOL_INCLUDES) async def network_new_pools( self, network: str, include: list | None = None, page: int = 1 ) -> dict: """Get new pools on a network""" ``` ```python async def main() -> None: agt = AsyncGeckoTerminalAPI() try: await agt.network_new_pools(network="arb") # invalid network -> 404 except GeckoTerminalAPIError as exc: print(exc.status) # 404 await agt.close() ``` -------------------------------- ### Sync client usage with version and proxies Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/configuration.md Usage example for the synchronous client with an API version and proxies. Shows how to instantiate GeckoTerminalAPI and inspect the base_url and accept_header attributes. ```python # Sync with version + proxies (README pattern) from geckoterminal_api import GeckoTerminalAPI proxies = { "http": "http://10.10.10.10:8000", "https": "http://10.10.10.10:8000", } gt = GeckoTerminalAPI(api_version="2023-12-19", proxies=proxies) print(gt.base_url) # https://api.geckoterminal.com/api/v2 print(gt.accept_header) # application/json;version=2023-12-19 ``` -------------------------------- ### network_dex_pools: Get top pools on a network's dex Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/async-client.md Retrieves top pools for a specific DEX on a network. The method signature shows the `@validate` decorator with `MAX_PAGE` and `NETWORK_POOL_INCLUDES`. The example calls `network_dex_pools` with `network="solana"` and `dex="raydium"`, then prints the first pool's name and closes the client. ```python @validate(max_page=MAX_PAGE, include_list=NETWORK_POOL_INCLUDES) async def network_dex_pools( self, network: str, dex: str, include: list | None = None, page: int = 1 ) -> dict: """Get top pools on a network's dex""" ``` ```python async def main() -> None: agt = AsyncGeckoTerminalAPI() pools = await agt.network_dex_pools(network="solana", dex="raydium") print(pools["data"][0]["attributes"]["name"]) await agt.close() ``` -------------------------------- ### Importing the public API Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/entry-point.md Example of importing the main client classes, exceptions, and constants from the package top level. ```python from geckoterminal_api import ( GeckoTerminalAPI, AsyncGeckoTerminalAPI, GeckoTerminalAPIError, GeckoTerminalParameterWarning, MAX_PAGE, TIMEFRAMES, ) ``` -------------------------------- ### networks() usage example Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/async-client.md Shows how to use the networks() method to fetch and print network IDs, then close the client. ```python import asyncio from geckoterminal_api import AsyncGeckoTerminalAPI async def main() -> None: agt = AsyncGeckoTerminalAPI() networks = await agt.networks() print([n["id"] for n in networks["data"]]) await agt.close() asyncio.run(main()) ``` -------------------------------- ### Call network_pool_ohlcv with basic parameters Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/sync-client-data.md Example call to network_pool_ohlcv with basic parameters. Iterates over the 'data' list and prints each candle's attributes. ```python ohlcv = gt.network_pool_ohlcv( network="eth", pool_address="0x60594a405d53811d3bc4766596efd80fd545a270", timeframe="hour", aggregate=4, ) for candle in ohlcv["data"]: print(candle["attributes"]) # e.g. {time, ohclv list: [open, high, low, close, volume]} ``` -------------------------------- ### Set up synchronous API proxy Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/README.md Configure HTTP and HTTPS proxies for the synchronous GeckoTerminalAPI client by passing a proxies dictionary to the constructor. ```python from geckoterminal_api import GeckoTerminalAPI proxies = { 'http': 'http://10.10.10.10:8000', 'https': 'http://10.10.10.10:8000', } gt = GeckoTerminalAPI(proxies=proxies) ``` -------------------------------- ### network_token_pools with include and page parameters Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/sync-client-data.md Calls the method with include=['base_token'] and page=1, then prints the number of pools returned. ```python pools = gt.network_token_pools( network="eth", token_address="0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", include=["base_token"], page=1, ) print(len(pools["data"])) ``` -------------------------------- ### Call token_info_recently_updated with include parameter Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/sync-client-data.md Example call to token_info_recently_updated with include=["network"]. Prints the attributes of the first token in the response. ```python updated = gt.token_info_recently_updated(include=["network"]) print(updated["data"][0]["attributes"]) ``` -------------------------------- ### trending_pools validation warning example Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/async-client.md Example showing how to capture the GeckoTerminalParameterWarning when calling trending_pools with an invalid include value. It uses warnings.catch_warnings to record and print the warning messages. ```python async def main() -> None: import warnings from geckoterminal_api import GeckoTerminalParameterWarning agt = AsyncGeckoTerminalAPI() with warnings.catch_warnings(record=True) as caught: warnings.simplefilter("always") await agt.trending_pools(include=["dex", "bogus"]) print([str(w.message) for w in caught]) await agt.close() ``` -------------------------------- ### GeckoTerminalAPI.__init__ Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/sync-client.md Constructor for the GeckoTerminalAPI client. Initializes the base URL, accept header, and a requests.Session with optional proxies. ```APIDOC ## GeckoTerminalAPI.__init__ ### Description Constructor for the GeckoTerminalAPI client. Initializes the base URL, accept header, and a requests.Session with optional proxies. ### Method Constructor ### Endpoint N/A (constructor) ### Parameters - **api_version** (str | None) - Optional - GeckoTerminal API version; when set, the Accept header becomes `application/json;version={api_version}`; when None, the latest version is requested with plain `application/json`. - **proxies** (dict[str, str] | None) - Optional - Proxy mapping assigned to `self._session.proxies` (standard requests proxies dict, e.g. `{"http": ..., "https": ...}`). ### Request Example ```python from geckoterminal_api import GeckoTerminalAPI gt = GeckoTerminalAPI() # with an explicit API version and proxies gt = GeckoTerminalAPI( api_version="2023-12-19", proxies={"http": "http://10.10.10.10:8000", "https": "http://10.10.10.10:8000"}, ) ``` ### Response #### Success Response - **base_url** (str) - Hardcoded base URL: `"https://api.geckoterminal.com/api/v2"`. - **accept_header** (str) - `f"application/json;version={api_version}"` if api_version else `"application/json"`. - **_session** (requests.Session) - Created eagerly in the constructor; proxies assigned only if provided. ``` -------------------------------- ### Call new_pools with defaults Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/sync-client.md Example call to new_pools with default parameters. It retrieves the newest pools and prints the name of the first pool in the response data. ```python newest = gt.new_pools() print(newest["data"][0]["attributes"]["name"]) ``` -------------------------------- ### network_trending_pools method and usage Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/async-client.md Shows the method signature for network_trending_pools and a usage example. The method is decorated with @validate to enforce max_page and include_list constraints. The example calls the method with network="solana" and prints the first pool id. ```python @validate(max_page=MAX_PAGE, include_list=NETWORK_POOL_INCLUDES) async def network_trending_pools( self, network: str, include: list | None = None, page: int = 1 ) -> dict: """Get trending pools on a network""" ``` ```python async def main() -> None: agt = AsyncGeckoTerminalAPI() pools = await agt.network_trending_pools(network="solana") print(pools["data"][0]["id"]) await agt.close() ``` -------------------------------- ### Import and assert limits constants with warnings capture Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/limits.md Shows how to import and use the constants, and how to capture GeckoTerminalParameterWarning when a page exceeds MAX_PAGE. The example asserts the values of MAX_PAGE and TIMEFRAMES within a warnings context that turns the warning into an error. ```python from geckoterminal_api import MAX_PAGE, MAX_ADDRESSES, TIMEFRAMES, TOKENS, CURRENCIES # Query a page beyond the documented maximum triggers a GeckoTerminalParameterWarning. # These constants are typically used with warnings capture, e.g.: import warnings from geckoterminal_api import GeckoTerminalParameterWarning with warnings.catch_warnings(): warnings.simplefilter("error", GeckoTerminalParameterWarning) assert MAX_PAGE == 10 assert TIMEFRAMES == ["day", "hour", "minute"] ``` -------------------------------- ### GET /search/pools Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/endpoints.md Searches for pools across networks. ```APIDOC ## GET /search/pools ### Description Searches for pools across networks. ### Method GET ### Endpoint /search/pools ### Query Parameters - **query** (string) - Required - The search query. ### Response #### Success Response (200) - **data** (array) - List of pool objects matching the search. ``` -------------------------------- ### GET /tokens/info_recently_updated Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/endpoints.md Returns tokens with recently updated information. ```APIDOC ## GET /tokens/info_recently_updated ### Description Returns tokens whose info has been recently updated. ### Method GET ### Endpoint /tokens/info_recently_updated ### Response #### Success Response (200) - **data** (array) - List of token objects with recent info updates. ``` -------------------------------- ### GET /networks/trending_pools Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/endpoints.md Returns trending pools across all networks. ```APIDOC ## GET /networks/trending_pools ### Description Returns trending pools across all networks. ### Method GET ### Endpoint /networks/trending_pools ### Response #### Success Response (200) - **data** (array) - List of trending pool objects. ``` -------------------------------- ### network_token_pools basic usage example Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/sync-client-data.md Calls the method with network and token_address, then prints pool names from the response data. ```python pools = gt.network_token_pools( network="eth", token_address="0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48" ) print([p["attributes"]["name"] for p in pools["data"]]) ``` -------------------------------- ### GET /networks/new_pools Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/endpoints.md Returns newly created pools across all networks. ```APIDOC ## GET /networks/new_pools ### Description Returns newly created pools across all networks. ### Method GET ### Endpoint /networks/new_pools ### Response #### Success Response (200) - **data** (array) - List of new pool objects. ``` -------------------------------- ### network_pool_info usage example Source: https://github.com/dineshpinto/geckoterminal-api/blob/main/_autodocs/api-reference/sync-client-data.md Shows a successful call to network_pool_info with network='eth' and a valid pool address, then prints the attributes from the response. ```python info = gt.network_pool_info( network="eth", pool_address="0x60594a405d53811d3bc4766596efd80fd545a270" ) print(info["data"]["attributes"]) ```