Skip to main content

JinkoOrgClient

JinkoOrgClient {#}​

JinkoOrgClient(
*,
api_key: str | None = None,
base_url: str | None = None,
app_url: str | None = None,
timeout: float = 30.0,
validate_config: bool = True,
transport: JinkoTransport | None = None
)

Client for the organization routes, with any API key of an organization.

The client lists and creates projects, lists, creates, and renames groups, and opens a regular JinkoClient for a project. It sends no project header. Use auth_check() to validate credentials and read key metadata. Use JinkoClient directly for work inside one project.

A project key also works here: it lists the projects of its owner, but it reaches only its own project. Project resource requests enforce key scope. A project client's auth_check() checks its key's declared scope too.

Example
from jinko import JinkoOrgClient

org = JinkoOrgClient() # reads JINKO_API_KEY and JINKO_BASE_URL
for project in org.list_projects():
print(project.id, project.name)

client = org.project(project.id)
client.search(limit=5)
MemberKindDescription
auth_checkmethodValidate credentials and return authentication status and key metadata.
list_projectsmethodList the organization projects visible to the API key.
create_projectmethodCreate a project in a group and return its identifier.
projectmethodOpen a project client reusing this key, base URL, app URL, and timeout.
list_groupsmethodList the groups in the organization.
get_groupmethodReturn one group.
create_groupmethodCreate a group and return its identifier.
update_groupmethodRename a group and return its identifier.
raw_requestmethodSend a raw request to the Jinko API with only the bearer token added.
set_timeoutmethodSet the timeout used for each request sent by this client.

auth_check​

auth_check() -> AuthCheckResult

Validate credentials and return authentication status and key metadata.

This check needs no project ID and works with project and organization keys. It does not check access to any project. Use a project client's auth_check() to check its key's declared scope, then request a project resource to verify access.

Raises:

list_projects​

list_projects(
*, name: str | None = None, group_id: str | None = None
) -> list[Project]

List the organization projects visible to the API key.

A key tied to a list of projects sees only those projects. Any other key sees the organization projects of its owner, including projects outside the key scope: a project key reaches only one of them.

Parameters:

NameTypeDescriptionDefault
namestr | NoneWhen set, keep projects whose name contains this text.None
group_idstr | NoneWhen set, keep projects that belong to this group.None

Returns:

  • list[Project]: The visible projects, in the key's order for a key tied to a list
  • list[Project]: of projects.

create_project​

create_project(
name: str, group_id: str, *, description: str | None = None
) -> ProjectRef

Create a project in a group and return its identifier.

The key owner creates the project. A key limited to a fixed list of projects cannot create one, because the new project would fall outside that list.

Parameters:

NameTypeDescriptionDefault
namestrName of the project.
group_idstrGroup the project is created in.
descriptionstr | NoneOptional description of the project.None

Returns:

  • ProjectRef: The identifier of the created project.

Raises:

project​

project(project: str | Project) -> JinkoClient

Open a project client reusing this key, base URL, app URL, and timeout.

This sends no request. Call auth_check() on the returned client to validate credentials and check the key's declared scope. It raises AuthenticationError for an out-of-scope project. Request a project resource to verify that the project exists and is accessible.

Parameters:

NameTypeDescriptionDefault
projectstr | ProjectA project returned by list_projects(), or a project id.

Returns:

list_groups​

list_groups(*, name: str | None = None) -> list[Group]

List the groups in the organization.

Parameters:

NameTypeDescriptionDefault
namestr | NoneWhen set, keep groups whose name contains this text.None

Returns:

  • list[Group]: The matching groups.

get_group​

get_group(group_id: str) -> Group

Return one group.

Parameters:

NameTypeDescriptionDefault
group_idstrIdentifier of the group.

Returns:

  • Group: The group.

create_group​

create_group(name: str, *, parent_id: str | None = None) -> GroupRef

Create a group and return its identifier.

Parameters:

NameTypeDescriptionDefault
namestrName of the group.
parent_idstr | NoneWhen set, the new group is created under this group.None

Returns:

  • GroupRef: The identifier of the created group.

update_group​

update_group(group_id: str, name: str) -> GroupRef

Rename a group and return its identifier.

Parameters:

NameTypeDescriptionDefault
group_idstrIdentifier of the group.
namestrNew name of the group.

Returns:

  • GroupRef: The identifier of the renamed group.

raw_request​

raw_request(
method: str,
path: str,
*,
params: dict[str, Any] | None = None,
json_body: Any | None = None,
data: bytes | None = None,
headers: dict[str, str] | None = None,
accept: str | None = None,
content_type: str | None = None
) -> Any

Send a raw request to the Jinko API with only the bearer token added.

set_timeout​

set_timeout(value: float | int | None)

Set the timeout used for each request sent by this client.