Skip to main content
POST
/
projects
/
{project_id}
/
keys
/
search
cURL
curl "https://api.phrase.com/v2/projects/:project_id/keys/search" \
  -u USERNAME_OR_ACCESS_TOKEN \
  -X POST \
  -d '{"branch":"my-feature-branch","sort":"updated_at","order":"desc","q":"mykey* translated:true","locale_id":"abcd1234abcd1234abcd1234abcd1234"}' \
  -H 'Content-Type: application/json'
phrase keys search \
--project_id <project_id> \
--data '{"branch":"my-feature-branch", "sort":"updated_at", "order":"desc", "q":"'mykey* translated:true'", "locale_id":"abcd1234abcd1234abcd1234abcd1234"}' \
--access_token <token>
import requests

url = "https://api.phrase.com/v2/projects/{project_id}/keys/search"

payload = {
"branch": "my-feature-branch",
"sort": "updated_at",
"order": "desc",
"q": "mykey* translated:true",
"locale_id": "abcd1234abcd1234abcd1234abcd1234"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
branch: 'my-feature-branch',
sort: 'updated_at',
order: 'desc',
q: 'mykey* translated:true',
locale_id: 'abcd1234abcd1234abcd1234abcd1234'
})
};

fetch('https://api.phrase.com/v2/projects/{project_id}/keys/search', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.phrase.com/v2/projects/{project_id}/keys/search",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'branch' => 'my-feature-branch',
'sort' => 'updated_at',
'order' => 'desc',
'q' => 'mykey* translated:true',
'locale_id' => 'abcd1234abcd1234abcd1234abcd1234'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.phrase.com/v2/projects/{project_id}/keys/search"

payload := strings.NewReader("{\n \"branch\": \"my-feature-branch\",\n \"sort\": \"updated_at\",\n \"order\": \"desc\",\n \"q\": \"mykey* translated:true\",\n \"locale_id\": \"abcd1234abcd1234abcd1234abcd1234\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.phrase.com/v2/projects/{project_id}/keys/search")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"branch\": \"my-feature-branch\",\n \"sort\": \"updated_at\",\n \"order\": \"desc\",\n \"q\": \"mykey* translated:true\",\n \"locale_id\": \"abcd1234abcd1234abcd1234abcd1234\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.phrase.com/v2/projects/{project_id}/keys/search")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"branch\": \"my-feature-branch\",\n \"sort\": \"updated_at\",\n \"order\": \"desc\",\n \"q\": \"mykey* translated:true\",\n \"locale_id\": \"abcd1234abcd1234abcd1234abcd1234\"\n}"

response = http.request(request)
puts response.read_body
[
  {
    "id": "abcd1234cdef1234abcd1234cdef1234",
    "name": "home.index.headline",
    "description": "My description for this key...",
    "name_hash": "1b31d2580ce324f246f66b3be00ed399",
    "plural": false,
    "use_ordinal_rules": false,
    "tags": [
      "awesome-feature",
      "needs-proofreading"
    ],
    "data_type": "string",
    "created_at": "2015-01-28T09:52:53Z",
    "updated_at": "2015-01-28T09:52:53Z"
  }
]

Authorizations

Authorization
string
header
required

Enter your token in the format token TOKEN

Headers

X-PhraseApp-OTP
string

Two-Factor-Authentication token (optional)

Path Parameters

project_id
string
required

Project ID

Query Parameters

page
integer

Page number

per_page
integer

Limit on the number of objects to be returned, between 1 and 100. 25 by default

Body

application/json
branch
string

specify the branch to use

Example:

"my-feature-branch"

sort
string

Sort by field. Can be one of: name, created_at, updated_at.

Example:

"updated_at"

order
string

Order direction. Can be one of: asc, desc.

Example:

"desc"

q
string

Specify a query to do broad search for keys by name (including wildcards).

The following qualifiers are also supported in the search term:

  • ids:key_id,... for queries on a comma-separated list of ids
  • name:key_name,... for text queries on a comma-seperated list of exact key names - spaces, commas, and colons need to be escaped with double backslashes
  • tags:tag_name,... to filter for keys with certain comma-seperated list of tags
  • uploads:upload_id,... to filter for keys with certain comma-seperated list of uploads
  • job:{true|false} to filter for keys mentioned in an active job
  • translated:{true|false} for translation status (also requires locale_id to be specified)
  • updated_at:{>=|<=}2013-02-21T00:00:00Z for date range queries
  • unmentioned_in_upload:upload_id,... to filter keys unmentioned within upload. When multiple upload IDs provided, matches only keys not mentioned in all uploads

Find more examples here. Please note: If tags are added to filter the search, the search will be limited to a maximum of 65,536 tagged keys.

Example:

"mykey* translated:true"

locale_id
string

Locale used to determine the translation state of a key when filtering for untranslated or translated keys.

Example:

"abcd1234abcd1234abcd1234abcd1234"

Response

OK

id
string
name
string
description
string
name_hash
string
plural
boolean
use_ordinal_rules
boolean
tags
string[]
data_type
string
created_at
string<date-time>
updated_at
string<date-time>