Tip
The features described on this page are not available in the public service. Contact us to know more.
Interaction with the Deep Search APIs¶
Autogenerated API clients¶
The SDK is also exposing the Swagger/OpenAPI autogenerated sdk clients. They can be used for interaction with all the CPS API endpoints.
For more details, refer to the autogenerated docs.
Usage of the Swagger SDK¶
from deepsearch.cps.client.api import CpsApi
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
# Import of the bare Swagger clients
from deepsearch.cps.apis import public as sw_client
api = CpsApi.from_env()
# Initialize the Swagger client, e.g. the `KnowledgeGraphsApi`
sw_kg_api = sw_client.KnowledgeGraphsApi(api.client.swagger_client)
# ...use the Swagger client directly
Interacting with the API directly via requests
¶
Another option is interacting with the CPS API directly using the endpoints. CPS provides a Swagger UI for inspecting all API endpoints (documented with schemas). To access the API documentation please use the following URLs:
- User API: https://{HOST}/api/cps/user/v1/ui/
- Public API: https://{HOST}/api/cps/public/v1/ui/
For example: - User API: https://deepsearch-experience.res.ibm.com/api/cps/user/v1/ui/ - Public API: https://deepsearch-experience.res.ibm.com/api/cps/public/v1/ui/
Once find the endpoint for your request, you can use it with this example code.
from deepsearch.cps.client.api import CpsApi
api = CpsApi.from_env()
cps_api_url = api.client.swagger_client.configuration.host
# For example, get list of KGs via the endpoint `/backend/project/{proj_key}/bags`
proj_key = "abc123"
r = api.client.session.get(f"{cps_api_url}/backend/project/{proj_key}/bags")
r.raise_for_status()
print(r.json())