Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,12 @@ git tag v0.1.0
git push origin v0.1.0
```

## Getting help

- **Bug reports and feature requests** - [GitHub Issues](https://github.com/ionq/ionq-core-python/issues)
- **Account, billing, or QPU questions** - [IonQ Support](https://ionq.com/contact)
- **API documentation** - [docs.ionq.com](https://docs.ionq.com/)

## License

Apache-2.0. See [LICENSE](LICENSE) for details.
73 changes: 1 addition & 72 deletions custom-templates/package_init.py.jinja
Original file line number Diff line number Diff line change
@@ -1,76 +1,5 @@
{% from "helpers.jinja" import safe_docstring %}
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

"""A Python client library for the [IonQ Cloud Platform API](https://docs.ionq.com/).

Provides full access to IonQ's quantum computing services with typed models for all
request and response objects. Supports both synchronous and asynchronous usage.

## Quick start

```python
from ionq_core import IonQClient
from ionq_core.api.backends import get_backends

# Authenticate with the IONQ_API_KEY environment variable
client = IonQClient()

# List available quantum backends
for backend in get_backends.sync(client=client):
print(f"{backend.backend}: {backend.status}")
```

## Authentication

Get an API key from the [IonQ Cloud Console](https://cloud.ionq.com), then
either set the ``IONQ_API_KEY`` environment variable or pass it directly:

```python
client = IonQClient() # reads IONQ_API_KEY
client = IonQClient(api_key="your-key") # explicit key
```

## Submitting a job

```python
from ionq_core.api.default import create_job
from ionq_core.models.circuit_job_creation_payload import CircuitJobCreationPayload

job = create_job.sync(
client=client,
body=CircuitJobCreationPayload.from_dict({
"type": "ionq.circuit.v1",
"backend": "simulator",
"shots": 1000,
"input": {
"gateset": "qis",
"circuit": [
{"gate": "h", "targets": [0]},
{"gate": "cnot", "targets": [0], "controls": [1]},
],
},
}),
)
```

## Key features

- **Sync and async** - every endpoint has ``.sync()`` and ``.asyncio()`` variants.
- **Automatic retries** - transient errors (429, 5xx) are retried with exponential
backoff. See `IonQClient` for configuration.
- **Typed exceptions** - HTTP errors are raised as `AuthenticationError`,
`RateLimitError`, `ServerError`, etc. See `_exceptions` for the full hierarchy.
- **Pagination helpers** - `iter_jobs` and `aiter_jobs` follow cursors automatically.
- **Job polling** - `wait_for_job` and `async_wait_for_job` poll until completion.
- **Session management** - `SessionManager` wraps the session lifecycle as a
context manager.
- **Native gate matrices** - `gpi_matrix`, `gpi2_matrix`, `ms_matrix`, and
`zz_matrix` return pure-Python unitary matrices for simulation and verification.
- **Extensibility** - `ClientExtension` lets downstream SDKs inject hooks, headers,
custom transports, and error mappers without modifying this library.
"""

{{ safe_docstring(package_description) }}
from ._exceptions import (
APIConnectionError,
APIError,
Expand Down
71 changes: 1 addition & 70 deletions ionq_core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,76 +1,7 @@
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

"""A Python client library for the [IonQ Cloud Platform API](https://docs.ionq.com/).

Provides full access to IonQ's quantum computing services with typed models for all
request and response objects. Supports both synchronous and asynchronous usage.

## Quick start

```python
from ionq_core import IonQClient
from ionq_core.api.backends import get_backends

# Authenticate with the IONQ_API_KEY environment variable
client = IonQClient()

# List available quantum backends
for backend in get_backends.sync(client=client):
print(f"{backend.backend}: {backend.status}")
```

## Authentication

Get an API key from the [IonQ Cloud Console](https://cloud.ionq.com), then
either set the ``IONQ_API_KEY`` environment variable or pass it directly:

```python
client = IonQClient() # reads IONQ_API_KEY
client = IonQClient(api_key="your-key") # explicit key
```

## Submitting a job

```python
from ionq_core.api.default import create_job
from ionq_core.models.circuit_job_creation_payload import CircuitJobCreationPayload

job = create_job.sync(
client=client,
body=CircuitJobCreationPayload.from_dict(
{
"type": "ionq.circuit.v1",
"backend": "simulator",
"shots": 1000,
"input": {
"gateset": "qis",
"circuit": [
{"gate": "h", "targets": [0]},
{"gate": "cnot", "targets": [0], "controls": [1]},
],
},
}
),
)
```

## Key features

- **Sync and async** - every endpoint has ``.sync()`` and ``.asyncio()`` variants.
- **Automatic retries** - transient errors (429, 5xx) are retried with exponential
backoff. See `IonQClient` for configuration.
- **Typed exceptions** - HTTP errors are raised as `AuthenticationError`,
`RateLimitError`, `ServerError`, etc. See `_exceptions` for the full hierarchy.
- **Pagination helpers** - `iter_jobs` and `aiter_jobs` follow cursors automatically.
- **Job polling** - `wait_for_job` and `async_wait_for_job` poll until completion.
- **Session management** - `SessionManager` wraps the session lifecycle as a
context manager.
- **Native gate matrices** - `gpi_matrix`, `gpi2_matrix`, `ms_matrix`, and
`zz_matrix` return pure-Python unitary matrices for simulation and verification.
- **Extensibility** - `ClientExtension` lets downstream SDKs inject hooks, headers,
custom transports, and error mappers without modifying this library.
"""
"""A client library for accessing IonQ Cloud Platform API"""

from ._exceptions import (
APIConnectionError,
Expand Down
3 changes: 3 additions & 0 deletions ionq_core/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

""" Contains methods for accessing the API """
3 changes: 3 additions & 0 deletions ionq_core/api/backends/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

""" Contains endpoint functions for accessing the API """
3 changes: 3 additions & 0 deletions ionq_core/api/backends/get_backend.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

from http import HTTPStatus
from typing import Any, cast
from urllib.parse import quote
Expand Down
3 changes: 3 additions & 0 deletions ionq_core/api/backends/get_backends.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

from http import HTTPStatus
from typing import Any, cast
from urllib.parse import quote
Expand Down
3 changes: 3 additions & 0 deletions ionq_core/api/characterizations/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

""" Contains endpoint functions for accessing the API """
3 changes: 3 additions & 0 deletions ionq_core/api/characterizations/get_characterization.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

from http import HTTPStatus
from typing import Any, cast
from urllib.parse import quote
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

from http import HTTPStatus
from typing import Any, cast
from urllib.parse import quote
Expand Down
3 changes: 3 additions & 0 deletions ionq_core/api/default/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

""" Contains endpoint functions for accessing the API """
3 changes: 3 additions & 0 deletions ionq_core/api/default/cancel_job.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

from http import HTTPStatus
from typing import Any, cast
from urllib.parse import quote
Expand Down
3 changes: 3 additions & 0 deletions ionq_core/api/default/cancel_jobs.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

from http import HTTPStatus
from typing import Any, cast
from urllib.parse import quote
Expand Down
3 changes: 3 additions & 0 deletions ionq_core/api/default/create_job.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

from http import HTTPStatus
from typing import Any, cast
from urllib.parse import quote
Expand Down
3 changes: 3 additions & 0 deletions ionq_core/api/default/create_session.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

from http import HTTPStatus
from typing import Any, cast
from urllib.parse import quote
Expand Down
3 changes: 3 additions & 0 deletions ionq_core/api/default/delete_job.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

from http import HTTPStatus
from typing import Any, cast
from urllib.parse import quote
Expand Down
3 changes: 3 additions & 0 deletions ionq_core/api/default/delete_jobs.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

from http import HTTPStatus
from typing import Any, cast
from urllib.parse import quote
Expand Down
3 changes: 3 additions & 0 deletions ionq_core/api/default/end_session.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

from http import HTTPStatus
from typing import Any, cast
from urllib.parse import quote
Expand Down
3 changes: 3 additions & 0 deletions ionq_core/api/default/estimate_job_cost.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

from http import HTTPStatus
from typing import Any, cast
from urllib.parse import quote
Expand Down
3 changes: 3 additions & 0 deletions ionq_core/api/default/get_compiled_file.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

from http import HTTPStatus
from typing import Any, cast
from urllib.parse import quote
Expand Down
3 changes: 3 additions & 0 deletions ionq_core/api/default/get_job.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

from http import HTTPStatus
from typing import Any, cast
from urllib.parse import quote
Expand Down
3 changes: 3 additions & 0 deletions ionq_core/api/default/get_job_cost.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

from http import HTTPStatus
from typing import Any, cast
from urllib.parse import quote
Expand Down
3 changes: 3 additions & 0 deletions ionq_core/api/default/get_job_probabilities.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

from http import HTTPStatus
from typing import Any, cast
from urllib.parse import quote
Expand Down
3 changes: 3 additions & 0 deletions ionq_core/api/default/get_jobs.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

from http import HTTPStatus
from typing import Any, cast
from urllib.parse import quote
Expand Down
3 changes: 3 additions & 0 deletions ionq_core/api/default/get_session.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

from http import HTTPStatus
from typing import Any, cast
from urllib.parse import quote
Expand Down
3 changes: 3 additions & 0 deletions ionq_core/api/default/get_session_jobs.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

from http import HTTPStatus
from typing import Any, cast
from urllib.parse import quote
Expand Down
3 changes: 3 additions & 0 deletions ionq_core/api/default/get_sessions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

from http import HTTPStatus
from typing import Any, cast
from urllib.parse import quote
Expand Down
3 changes: 3 additions & 0 deletions ionq_core/api/default/get_variant_histogram.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

from http import HTTPStatus
from typing import Any, cast
from urllib.parse import quote
Expand Down
3 changes: 3 additions & 0 deletions ionq_core/api/default/get_variant_probabilities.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

from http import HTTPStatus
from typing import Any, cast
from urllib.parse import quote
Expand Down
3 changes: 3 additions & 0 deletions ionq_core/api/default/get_variant_shots.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

from http import HTTPStatus
from typing import Any, cast
from urllib.parse import quote
Expand Down
3 changes: 3 additions & 0 deletions ionq_core/api/usage/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

""" Contains endpoint functions for accessing the API """
3 changes: 3 additions & 0 deletions ionq_core/api/usage/get_usages.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

from http import HTTPStatus
from typing import Any, cast
from urllib.parse import quote
Expand Down
3 changes: 3 additions & 0 deletions ionq_core/api/whoami/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

""" Contains endpoint functions for accessing the API """
3 changes: 3 additions & 0 deletions ionq_core/api/whoami/get_whoami.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

from http import HTTPStatus
from typing import Any, cast
from urllib.parse import quote
Expand Down
3 changes: 3 additions & 0 deletions ionq_core/client.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

import ssl
from typing import Any

Expand Down
3 changes: 3 additions & 0 deletions ionq_core/errors.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

""" Contains shared errors types that can be raised from API functions """

class UnexpectedStatus(Exception):
Expand Down
3 changes: 3 additions & 0 deletions ionq_core/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2026 IonQ, Inc.
# SPDX-License-Identifier: Apache-2.0

""" Contains all the data models used in inputs/outputs """

from .add_job_results_payload import AddJobResultsPayload
Expand Down
Loading
Loading