Asynchronous client
This is the client to be used for retrieving the GDS information in an asynchronous (i.e. non-blocking) fashion.
import asyncio
from pysdmx.api.gds import AsyncGdsClient
async def main():
gr = AsyncGdsClient()
gds_agencies = await gr.get_agencies("BIS")
print(gds_agencies)
asyncio.run(main())
Important
This client is designed to be used with Python’s asyncio library. Ensure you have an event loop running when using this client.
The asynchronous client is recommended for asynchronous workflows based on fastapi or similar frameworks.
from fastapi import FastAPI
from pysdmx.api.gds import AsyncGdsClient
app = FastAPI()
@app.get("/agencies/{agency_id}")
async def get_agencies(agency_id: str):
client = AsyncGdsClient()
agencies = await client.get_agencies(agency_id)
return {"agencies": agencies}
Note
For more details over the connectors, check the GDS Synchronous client documentation. The async client supports the same parameters and methods as the synchronous client, but operates asynchronously.
- class pysdmx.api.gds.AsyncGdsClient(api_endpoint='https://gds.sdmx.io/', pem=None)
A client to be used to retrieve metadata from the GDS asynchronously.
- async get_agencies(agency)
Get the list of agencies for the supplied name asynchronously.
- Parameters:
agency (
str
) – The agency maintaining the agency scheme.- Return type:
Sequence
[Agency
]- Returns:
The requested list of agencies.
- async get_catalogs(catalog, resource='*', version='*', resource_type=None, message_format=None, api_version=None, detail=None, references=None)
Get the list of catalogs for the supplied params asynchronously.
- Return type:
Sequence
[GdsCatalog
]
- async get_sdmx_apis(api_version='*')
Get the list of SDMX API versions asynchronously.
- Return type:
Sequence
[GdsSdmxApi
]
- async get_services(service, resource='*', version='*')
Get a list of services for the supplied params asynchronously.
- Return type:
Sequence
[GdsService
]
- async get_urn_resolver(urn)
Resolve a URN to its corresponding resource asynchronously.
- Return type: