Skip to content

Request/Response schemas

We validate request parameters and responses with pydantic to try and provide more certainty about the data sent and received from the OLS API. This should also mean you get useful type annotations when working with the client in your own code (you may want to install a Pydantic plugin for your IDE/editor, e.g. VS Code).

ols_py.schemas.requests

GetTermsParams

Optional arguments for get_terms() method

PageParams

Pagination params accepted by endpoints that return multiple resources

page: Optional[NonNegativeInt] = None class-attribute instance-attribute

Which page to fetch (starting at 0)

size: Optional[PositiveInt] = None class-attribute instance-attribute

Number of results per page

SearchParams

Optional parameters passed to search() method (not including the q/query parameter).

NOTE: use get_query_dict() to convert this to the format needed by the GET request

allChildrenOf: NotRequired[list[str]] instance-attribute

Restrict results to children of these terms, plus other child-like relations e.g. "part of", "develops from"

childrenOf: NotRequired[list[str]] instance-attribute

Restrict results to children of these terms

exact: NotRequired[bool] instance-attribute

Only return exact matches

fieldList: NotRequired[list[SearchReturnFields | AnnotationFieldName]] instance-attribute

Which fields to return in the results

groupField: NotRequired[bool] instance-attribute

Group results by unique ID

local: NotRequired[bool] instance-attribute

Only return terms in a defining ontology

obsoletes: NotRequired[bool] instance-attribute

Include obsoleted terms in the results

ontology: NotRequired[str | list[str]] instance-attribute

Ontologies to search, e.g. ["mondo", "upheno"]

queryFields: NotRequired[list[SearchQueryFields | AnnotationFieldName]] instance-attribute

Which fields to search over

rows: NotRequired[int] instance-attribute

Number of results per page

start: NotRequired[int] instance-attribute

Index of first result

type: NotRequired[EntityType] instance-attribute

Type of term to search for, e.g. "class", "property"

SelectParams

Optional parameters passed to select() method (not including the q/query parameter).

NOTE: use get_query_dict() to convert this to the format needed by the GET request

allChildrenOf: NotRequired[list[str]] instance-attribute

Restrict results to children of these terms, plus other child-like relations e.g. "part of", "develops from"

childrenOf: NotRequired[list[str]] instance-attribute

Restrict results to children of these terms

exact: NotRequired[bool] instance-attribute

Only return exact matches

fieldList: NotRequired[list[SearchReturnFields | AnnotationFieldName]] instance-attribute

Which fields to return in the results

groupField: NotRequired[bool] instance-attribute

Group results by unique ID

local: NotRequired[bool] instance-attribute

Only return terms in a defining ontology

obsoletes: NotRequired[bool] instance-attribute

Include obsoleted terms in the results

ontology: NotRequired[str | list[str]] instance-attribute

Ontologies to search, e.g. ["mondo", "upheno"]

rows: NotRequired[int] instance-attribute

Number of results per page

start: NotRequired[int] instance-attribute

Index of first result

type: NotRequired[EntityType] instance-attribute

Type of term to search for, e.g. "class", "property"

TermInDefiningOntologyParams

Optional arguments for get_term_in_defining_ontology() method

get_query_dict(params: SearchParams | SelectParams) -> dict[str, str]

Convert SearchParams or SelectParams to the format needed in requests, converting any list values to comma-separated string, as required by the search and select endpoints

ols_py.schemas.responses

ApiInfo

Response returned by the root API endpoint, links to other endpoints/resources

Set of links returned in the root endpoint/ API ifno

EmbeddedTerms

"_embedded" field used in responses returning terms

Link item returned in responses

MultipleTerms

Response returned for endpoints which return multiple term results, e.g. parents, ancestors, descendants etc. The actual terms are at response.embedded.terms

OlsErrorSchema

Error data returned the OLS API for a bad request/error

PageInfo

Page information returned in paginated responses

Term

Response returned by term endpoints

TermInDefiningOntology

Response returned for /terms/findByIdAndIsDefiningOntology/ endpoint