Skip to main content

Python SDK for Nadeshiko API (public endpoints only)

Project description

Nadeshiko SDK

Python SDK for the Nadeshiko API.

Install

pip install nadeshiko-sdk

Use the public SDK

The client sends your API key as Authorization: Bearer <apiKey>.

import os

from nadeshiko import Nadeshiko
from nadeshiko.api.search import search
from nadeshiko.models import Error, SearchRequest

client = Nadeshiko(
    base_url=os.getenv("NADESHIKO_BASE_URL", "https://api.nadeshiko.co"),
    token=os.getenv("NADESHIKO_API_KEY", "your-api-key"),
)

result = search.sync(
    client=client,
    body=SearchRequest(query="彼女"),
)

if isinstance(result, Error):
    print(result.code, result.detail)
else:
    for sentence in result.sentences:
        print(sentence.segment_info.content_jp)

Error handling

Every response returns either a typed response object or an Error. The Error object follows the RFC 7807 Problem Details format, so you always get a machine-readable code and a human-readable detail.

import os

from nadeshiko import Nadeshiko
from nadeshiko.api.search import search
from nadeshiko.models import Error, SearchRequest

client = Nadeshiko(
    base_url=os.getenv("NADESHIKO_BASE_URL", "https://api.nadeshiko.co"),
    token=os.getenv("NADESHIKO_API_KEY", "your-api-key"),
)

result = search.sync(
    client=client,
    body=SearchRequest(query="食べる"),
)

if isinstance(result, Error):
    match result.code:
        # 400 — Bad Request
        case "VALIDATION_FAILED":
            print("Validation failed:", result.detail)
        case "INVALID_JSON":
            print("Malformed JSON body:", result.detail)
        case "INVALID_REQUEST":
            print("Invalid request:", result.detail)

        # 401 — Unauthorized
        case "AUTH_CREDENTIALS_REQUIRED":
            print("Missing API key or session token")
        case "AUTH_CREDENTIALS_INVALID":
            print("API key is invalid")
        case "AUTH_CREDENTIALS_EXPIRED":
            print("Token has expired, re-authenticate")
        case "EMAIL_NOT_VERIFIED":
            print("Email verification required")

        # 403 — Forbidden
        case "ACCESS_DENIED":
            print("Access denied")
        case "INSUFFICIENT_PERMISSIONS":
            print("API key lacks the required scope")

        # 429 — Too Many Requests
        case "RATE_LIMIT_EXCEEDED":
            print("Rate limit hit, slow down")
        case "QUOTA_EXCEEDED":
            print("Monthly quota exhausted")

        # 500 — Internal Server Error
        case "INTERNAL_SERVER_EXCEPTION":
            print("Server error, trace ID:", result.instance)
else:
    for sentence in result.sentences:
        print(sentence.segment_info.content_jp, "—", sentence.basic_info.name_anime_en)

See examples/examples.py for more usage patterns.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nadeshiko_sdk-2.0.3.tar.gz (63.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nadeshiko_sdk-2.0.3-py3-none-any.whl (202.7 kB view details)

Uploaded Python 3

File details

Details for the file nadeshiko_sdk-2.0.3.tar.gz.

File metadata

  • Download URL: nadeshiko_sdk-2.0.3.tar.gz
  • Upload date:
  • Size: 63.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nadeshiko_sdk-2.0.3.tar.gz
Algorithm Hash digest
SHA256 a0c8b38c8f8d27a896afe6694ba8b62e7108b8c44e8374c4acfef4111f52a1f6
MD5 8daeaacf56e7632e1537787cf4554c5f
BLAKE2b-256 705516f4ad742f7f7a10c2e0de1ee5832ac4f81a1ec75d1dc332dc0c8f7f3c09

See more details on using hashes here.

Provenance

The following attestation bundles were made for nadeshiko_sdk-2.0.3.tar.gz:

Publisher: release.yml on BrigadaSOS/nadeshiko-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nadeshiko_sdk-2.0.3-py3-none-any.whl.

File metadata

  • Download URL: nadeshiko_sdk-2.0.3-py3-none-any.whl
  • Upload date:
  • Size: 202.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nadeshiko_sdk-2.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a58ee70a87f5421725a9699fb841dbec750cbb3b9c3278f802cdcd536aebc84d
MD5 704479007ac2d10adae772433b2c9396
BLAKE2b-256 631ba1eb64f856aca753828de4515e232e3cd89116fe491415597e56e3ec2f90

See more details on using hashes here.

Provenance

The following attestation bundles were made for nadeshiko_sdk-2.0.3-py3-none-any.whl:

Publisher: release.yml on BrigadaSOS/nadeshiko-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page