Keys endpoint¶
Fetch all keys¶
- keys(project_id[, params=None])¶
- Parameters:
project_id (str) – ID of the project
params (dict) – Request parameters
- Returns:
Collection of keys
Please note that this endpoint should not be treated as a content delivery network for your language files. It means that you should not perform a new request to this endpoint with every website/app visitor. Instead, fetch this endpoint from time to time, store the result locally and serve your visitors with static files/your database content. Alternatively, you may use our Amazon S3/Google CloudStorage integrations in automatically upload your language files to a bucket of your choice.
Example:
client.keys('123.abc', {
"page": 2,
"limit": 3,
"disable_references": "1",
"filter_archived": "exclude"
})
Create keys¶
- create_keys(project_id, params)¶
- Parameters:
project_id (str) – ID of the project
params (list or dict) – Keys parameters
- Returns:
Keys collection
Example:
client.create_keys('123.abc', [
{
"key_name": "python_1",
"platforms": ["ios", "android"],
"description": "Created by Python"
},
{
"key_name": "python_2",
"platforms": ["web"],
"translations": [
{
"language_iso": "en",
"translation": "Hi from Python"
}
]
}
])
Fetch a key¶
- key(project_id, key_id[, params=None])¶
- Parameters:
project_id (str) – ID of the project
key_id – ID of the key to fetch
params (dict) – Request parameters
- Returns:
Key model
Example:
key = client.key('123.abc', 3456, {"disable_references": "1"})
key.key_id # => 3456
key.key_name['ios'] # => "manual_setup"
Update a key¶
- update_key(project_id, key_id[, params = None])¶
- Parameters:
project_id (str) – ID of the project
key_id – ID of the key to update
params (dict) – Request parameters
- Returns:
Key model
Example:
key = client.update_key('123.abc', 3456, {
"description": "Updated by Python",
"tags": ["python"]
})
key.description # => "Updated by Python"
Bulk key update¶
- update_keys(project_id, params)¶
- Parameters:
project_id (str) – ID of the project
params (dict) – Key parameters
- Returns:
Key collection
Example:
keys = client.update_keys('123.abc', [
{
"key_id": 48855757,
"description": "Bulk updated",
"tags": ["bulk-python"]
},
{
"key_id": 48855758,
"translations": [
{
"language_iso": "en",
"translation": "Updated Python translation"
}
]
}
])
keys.items[0].description # => "Bulk updated"
Delete a key¶
- delete_key(project_id, key_id)¶
- Parameters:
project_id (str) – ID of the project
key_id (int or str) – ID of the key to delete
- Returns:
Dictionary with project ID and “key_removed” set to True
- Rtype dict:
Example:
client.delete_key('123.abc', 48850)
Delete multiple keys¶
- delete_keys(project_id, key_ids)¶
- Parameters:
project_id (str) – ID of the project
key_ids (list) – List of the key identifiers to delete
- Returns:
Dictionary with project ID and “keys_removed” set to True
- Rtype dict:
Example:
client.delete_keys('123.abc', [34567, 78913])