Skip to main content

Crowdin Python client Tweet GitHub Repo stars

The Crowdin Python client is a lightweight interface to the Crowdin API. It provides common services for making API requests.

Crowdin API is a full-featured RESTful API that helps you to integrate localization into your development process. The endpoints that we use allow you to easily make calls to retrieve information and to execute actions needed.

Installation

pip install crowdin-api-client

Quick Start

Create and list projects

from crowdin_api import CrowdinClient

class FirstCrowdinClient(CrowdinClient):
    TOKEN = "__token__"
    PROJECT_ID = 1 # Optional, set project id for all API's
    ORGANIZATION = "organizationName" # Optional, for Crowdin Enterprise only
    TIMEOUT = 60  # Optional, sets http request timeout.
    RETRY_DELAY = 0.1  # Optional, sets the delay between failed requests 
    MAX_RETRIES = 5  # Optional, sets the number of retries
    HEADERS = {"Some-Header": ""}  # Optional, sets additional http request headers
    PAGE_SIZE = 25  # Optional, sets default page size
    EXTENDED_REQUEST_PARAMS = {"some-parameters": ""}  # Optional, sets additional parameters for request

client = FirstCrowdinClient()

# Create Project
project_response = client.projects.add_project(name="New project", sourceLanguageId="en")

# Get list of Projects
projects = client.projects.list_projects()

# Get list of Projects with offset and limit
projects = client.projects.list_projects(offset=10, limit=20)

# Get list of Projects by page
projects = client.projects.list_projects(page=2) # offset=25, limit=25

Alternatively, you can create an instance of the CrowdinClient class with params like this:

from crowdin_api import CrowdinClient

# use the lower-case version of any of the constants above,
# at least provide token
client = CrowdinClient(token='__token__')

# ... continue as above

Add a file

from crowdin_api import CrowdinClient

client = CrowdinClient(token='__token__')

file_name = '__path_to_the_file__'

storage = client.storages.add_storage(open(file_name, 'rb'))

my_file = client.source_files.add_file(__project_id__, storage['data']['id'], file_name)

print(my_file)

Fetch all records

It is possible to fetch all records from paginatable methods (where we have limit and offset in arguments).

from crowdin_api import CrowdinClient

client = CrowdinClient(token='__token__')

# get all projects
print(client.projects.with_fetch_all().list_projects())

# get projects but not more than 1000
print(client.projects.with_fetch_all(1000).list_projects())

Sorting

An optional orderBy parameter is used to apply sorting.

from crowdin_api import CrowdinClient
from crowdin_api.sorting import Sorting, SortingOrder, SortingRule
from crowdin_api.api_resources.projects.enums import ListProjectsOrderBy

client = CrowdinClient(token='__token__')

sorting = Sorting(
    [
        SortingRule(ListProjectsOrderBy.ID, SortingOrder.ASC),
        SortingRule(ListProjectsOrderBy.NAME),
        SortingRule(ListProjectsOrderBy.CREATED_AT, SortingOrder.DESC),
    ]
)

print(client.projects.list_projects(orderBy=sorting))

Enum SortingOrder is also optional (ascending order applied by default).

Extended request parameters

The EXTENDED_REQUEST_PARAMS parameter allows you to set additional parameters for requests. For example, you can configure proxies or certificates.

The Client uses the requests library to make HTTP requests. You can pass any parameters that requests supports:

def request(
    self,
    method,
    url,
    params=None,
    data=None,
    headers=None,
    cookies=None,
    files=None,
    auth=None,
    timeout=None,
    allow_redirects=True,
    proxies=None,
    hooks=None,
    stream=None,
    verify=None,
    cert=None,
    json=None,
):

For example, you can set a proxy:

from crowdin_api import CrowdinClient

http_proxy = "http://10.10.1.10:3128"
https_proxy = "https://10.10.1.11:1080"
ftp_proxy = "ftp://10.10.1.10:3128"

proxies = {
  "http": http_proxy,
  "https": https_proxy,
  "ftp": ftp_proxy
}

class FirstCrowdinClient(CrowdinClient):
    EXTENDED_REQUEST_PARAMS = {"proxies": proxies}

GraphQL API

This library also provides the possibility to use GraphQL API:

from crowdin_api import CrowdinClient

client = CrowdinClient(
    token='{token}',
    organization='{organization}'
)

query = """
query {
  viewer {
    id
    name
  }
}
"""

# Execute the GraphQL query
response = client.graphql(query=query)

Seeking Assistance

If you find any problems or would like to suggest a feature, please read the How can I contribute section in our contributing guidelines.

Contributing

If you would like to contribute please read the Contributing guidelines.

License

The Crowdin Python client is licensed under the MIT License.
See the LICENSE file distributed with this work for additional
information regarding copyright ownership.

Except as contained in the LICENSE file, the name(s) of the above copyright
holders shall not be used in advertising or otherwise to promote the sale,
use or other dealings in this Software without prior written authorization.

Release files for crowdin-api-client 1.29.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for crowdin-api-client 1.29.0
File Size Uploaded
crowdin_api_client-1.29.0.tar.gz 74.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for crowdin-api-client 1.29.0
File Interpreter ABI Platform
crowdin_api_client-1.29.0-py3-none-any.whl Python 3 none any Details

Total release size: 190.4 kB

Release files / crowdin_api_client-1.29.0.tar.gz

Download URL crowdin_api_client-1.29.0.tar.gz
Size 74.7 kB
Tags Source
SHA-256 checksum
How to use checksums
becdb4103e0d3d6e2a5b5c129ad7850f0f8631da24bb46703c2b2d7befa4a5d7
BLAKE2b-256 checksum
How to use checksums
2ca3b357800b5996d5475de875187327f917b00fd34f614b428ca0d88bcf58e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / crowdin_api_client-1.29.0-py3-none-any.whl

Download URL crowdin_api_client-1.29.0-py3-none-any.whl
Size 115.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2f16a27ff71a518b35f0b0209336f1a044aef26001c8bbcd546a6d18d2d9e3c2
BLAKE2b-256 checksum
How to use checksums
e023184b601011cb42d8a740eb6174406234d3d4fa40bf8aceec3155464c7a64
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

1.29.0 This release

2 release files

1.28.0

2 release files

1.25.0

2 release files

1.24.1

2 release files

1.24.0

2 release files

1.23.0

2 release files

1.22.0

2 release files

1.21.0

2 release files

1.20.0

2 release files

1.18.1

2 release files

1.16.0

2 release files

1.15.2

2 release files

1.15.1

2 release files

1.14.1

2 release files

1.14.0

2 release files

1.12.1

2 release files

1.12.0

2 release files

1.10.1

2 release files

1.10.0

2 release files

1.9.0

2 release files

1.8.0

2 release files

1.7.0

2 release files

1.6.0

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page