API v2 Usage Examples

Learn how to work more efficiently with PhraseApp API v2 with these workflow-oriented examples.

Find excluded translations with a certain content

List excluded translations for the given project which start with the term PhraseApp.

Request

curl "https://api.phraseapp.com/api/v2/projects/:project_id/translations?sort=updated_at&order=desc&q=PhraseApp*%20excluded:true" \
  -u USERNAME_OR_ACCESS_TOKEN
phraseapp translations list <project_id> \
--sort updated_at \
--order desc \
--query 'PhraseApp* excluded:true'

Find unverified translations with a certain content

List unverified translations for the given project which start with the term PhraseApp and are not verified.

Request

curl "https://api.phraseapp.com/api/v2/projects/:project_id/translations?sort=updated_at&order=desc&q=PhraseApp*%20unverified:true" \
  -u USERNAME_OR_ACCESS_TOKEN
phraseapp translations list <project_id> \
--sort updated_at \
--order desc \
--query 'PhraseApp* unverified:true'

Verify translations selected by query

Verify all translations that are matching the query my dog.

Request

curl "https://api.phraseapp.com/api/v2/projects/:project_id/translations/verify" \
  -u USERNAME_OR_ACCESS_TOKEN \
  -X PATCH \
  -d '{"q":"my dog unverified:true","sort":"updated_at","order":"desc"}' \
  -H 'Content-Type: application/json'
phraseapp translations verify <project_id> \
--query "my dog unverified:true" \
--sort updated_at \
--order desc

Find recently updated keys

Find updated keys with with the updated_at qualifier like updated_at:>=2013-02-21T00:00:00Z. This example returns keys that have been updated on or after 2013-02-21.

Request

curl "https://api.phraseapp.com/api/v2/projects/:project_id/keys?sort=updated_at&order=desc&q=updated_at:%3E=2013-02-21T00:00:00Z&locale_id=abcd1234abcd1234abcd1234abcd1234" \
  -u USERNAME_OR_ACCESS_TOKEN
phraseapp keys list <project_id> \
--sort updated_at \
--order desc \
--query "updated_at:>=2013-02-21T00:00:00Z" \
--locale-id abcd1234abcd1234abcd1234abcd1234

Find keys with a certain tag

Keys with certain tags can be filtered with the qualifier tags:.

Request

curl "https://api.phraseapp.com/api/v2/projects/:project_id/keys?q=tags:admin" \
  -u USERNAME_OR_ACCESS_TOKEN
phraseapp keys list <project_id> \
--query "tags:admin"

Add tags to collection of keys

Add the tags landing-page and release-1.2 to all keys that start with dog and are translated in the locale abcd1234abcd1234abcd1234abcd1234.

Request

curl "https://api.phraseapp.com/api/v2/projects/:project_id/keys/tag" \
  -u USERNAME_OR_ACCESS_TOKEN \
  -X PATCH \
  -d '{"q":"dog* translated:true","tags":"landing-page,release-1.2","locale_id":"abcd1234abcd1234abcd1234abcd1234"}' \
  -H 'Content-Type: application/json'
phraseapp keys tag <project_id> \
--query 'dog* translated:true' \
--tags landing-page,release-1.2 \
--locale-id abcd1234abcd1234abcd1234abcd1234

Remove tags from collection of keys

Remove the tags landing-page and release-1.2 from all keys that start with dog and are translated in the locale abcd1234abcd1234abcd1234abcd1234.

Request

curl "https://api.phraseapp.com/api/v2/projects/:project_id/keys/untag" \
  -u USERNAME_OR_ACCESS_TOKEN \
  -X PATCH \
  -d '{"q":"dog* translated:true","tags":"landing-page,release-1.2","locale_id":"abcd1234abcd1234abcd1234abcd1234"}' \
  -H 'Content-Type: application/json'
phraseapp keys untag <project_id> \
--query 'dog* translated:true' \
--tags landing-page,release-1.2 \
--locale-id abcd1234abcd1234abcd1234abcd1234

Find keys with broad text match

Example query my dog

Request

curl "https://api.phraseapp.com/api/v2/projects/:project_id/keys?q=my%20dog" \
  -u USERNAME_OR_ACCESS_TOKEN
phraseapp keys list <project_id> \
--query "my dog"

Matches

My dog is lazy
my dog is lazy
angry dog in my house

Find keys with exact text match

Example query "my dog is lazy"

Request

curl "https://api.phraseapp.com/api/v2/projects/:project_id/keys?q=my%20dog%20is%20lazy" \
  -u USERNAME_OR_ACCESS_TOKEN
phraseapp keys list <project_id> \
--query "my dog is lazy"

Matches

My dog is lazy
my dog is lazy
angry dog in my house

Find keys with wildcard character matching

Example query *dog is*

Request

curl "https://api.phraseapp.com/api/v2/projects/:project_id/keys?q=*dog%20is*" \
  -u USERNAME_OR_ACCESS_TOKEN
phraseapp keys list <project_id> \
--query '*dog is*'

Matches

My dog is lazy
my dog is lazy
angry dog in my house