Reference for hub_sdk/base/api_client.py
Note
This file is available at https://github.com/ultralytics/hub-sdk/blob/main/hub_sdk/base/api_client.py. If you spot a problem please help fix it by contributing a Pull Request 🛠️. Thank you 🙏!
hub_sdk.base.api_client.APIClientError
Bases: Exception
Custom exception class for API client errors.
Attributes:
Name | Type | Description |
---|---|---|
message | str | A human-readable error message. |
status_code | int | The HTTP status code associated with the error, if available. |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message | str | A human-readable error message. | required |
status_code | int | The HTTP status code associated with the error, if available. | None |
Source code in hub_sdk/base/api_client.py
hub_sdk.base.api_client.APIClient
Represents an API client for making requests to a specified base URL.
Attributes:
Name | Type | Description |
---|---|---|
base_url | str | The base URL for the API. |
headers | (dict, None) | Headers to be included in each request. |
logger | Logger | An instance of the logger for logging purposes. |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base_url | str | The base URL for the API. | required |
headers | dict | Headers to be included in each request. | None |
Source code in hub_sdk/base/api_client.py
delete
Make a DELETE request to the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
endpoint | str | The endpoint to append to the base URL for the request. | required |
params | dict | Parameters to include in the request. | None |
Returns:
Type | Description |
---|---|
Optional[Response] | The response object from the HTTP DELETE request, or None if it fails. |
Source code in hub_sdk/base/api_client.py
get
Make a GET request to the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
endpoint | str | The endpoint to append to the base URL for the request. | required |
params | dict | Query parameters for the request. | None |
Returns:
Type | Description |
---|---|
Optional[Response] | The response object from the HTTP GET request, None if it fails. |
Source code in hub_sdk/base/api_client.py
patch
patch(
endpoint: str, data: Optional[Dict] = None, json: Optional[Dict] = None
) -> Optional[requests.Response]
Make a PATCH request to the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
endpoint | str | The endpoint to append to the base URL for the request. | required |
data | dict | Data to be sent in the request's body. | None |
json | dict | JSON data to be sent in the request's body. | None |
Returns:
Type | Description |
---|---|
Optional[Response] | The response object from the HTTP PATCH request, or None if it fails. |
Source code in hub_sdk/base/api_client.py
post
post(
endpoint: str,
data: Optional[Dict] = None,
json: Optional[Dict] = None,
files: Optional[Dict] = None,
stream=False,
) -> Optional[requests.Response]
Make a POST request to the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
endpoint | str | The endpoint to append to the base URL for the request. | required |
data | dict | Data to be sent in the request's body. | None |
json | dict | JSON data to be sent in the request's body. | None |
files | dict | Files to be included in the request, if any. | None |
stream | bool | If True, the response content will be streamed. | False |
Returns:
Type | Description |
---|---|
Optional[Response] | The response object from the HTTP POST request. |
Source code in hub_sdk/base/api_client.py
put
put(
endpoint: str, data: Optional[Dict] = None, json: Optional[Dict] = None
) -> Optional[requests.Response]
Make a PUT request to the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
endpoint | str | The endpoint to append to the base URL for the request. | required |
data | Optional[Dict] | Data to be sent in the request's body. | None |
json | Optional[Dict] | JSON data to be sent in the request's body | None |
Returns:
Type | Description |
---|---|
Optional[Response] | The response object from the HTTP PUT request. |