Transifex

  • Documentation
  • API
  • Screenshots

Screenshots

The screenshots endpoint handles READ/UPDATE operations for screenshots in a project.

Screenshots are identified by an id provided by Transifex.

Note

The screenshots endpoint is only available on the Enterprise plan.

Note that this feature of Transifex relies on two new API endpoints: api.transifex.com and usermedia.transifex.com. You must authenticate with a token when calling these endpoints.

Getting list of screenshots

URL:

api.transifex.com/organizations/<organization_slug>/projects/<project_slug>/context/screenshots/

GET

This request is used to get a list of screenshots in a project.

The response is a JSON list of screenshots in the project. For each screenshot, there is a dictionary with information about the screenshot:

  • id - the unique id of the screenshot
  • name - the name of the screenshot
  • media_url - the URL of the screenshot
  • thumb_url - the URL of the screenshots' thumbnail
  • created_by - username of the uploader
  • created - timestamp of the creation
  • modified - timestamp of modification
  • mapped_strings_count - the number of strings mapped to this screenshot

Example:

curl -i --user api:<token> -X GET https://api.transifex.com/organizations/transifex/projects/transifex/context/screenshots/

HTTP/1.0 200 OK
...
[
  {
    "id": 94376,        
    "name": "Home page",
    "media_url": "https://s3-eu-west-1.amazonaws.com/transifex-context/transifex/transifex/1cb3ff6c-65fa-4a41-8384-4eacaed7da3d_original",
    "thumb_url": "https://s3-eu-west-1.amazonaws.com/transifex-context/transifex/transifex/1cb3ff6c-65fa-4a41-8384-4eacaed7da3d_resized",
    "created": "2017-02-28T20:25:18.195987Z",
    "modified": "2017-02-28T20:25:18.196013Z",
    "created_by": "diegobz",
    "mapped_strings_count": 4
  },
  {
    "id": 92525,
    "name": "Screenshot 2016-11-08 12.21.21.png",
    "media_url": "https://s3-eu-west-1.amazonaws.com/transifex-context/transifex/transifex/1cb3ff6c-65fa-4a41-8384-4eacaed7da3d_original",
    "thumb_url": "https://s3-eu-west-1.amazonaws.com/transifex-context/transifex/transifex/1cb3ff6c-65fa-4a41-8384-4eacaed7da3d_resized",
    "created": "2016-11-08T10:36:58.510259Z",
    "modified": "2017-01-13T08:33:41.553153Z",
    "created_by": "nbasili",
    "mapped_strings_count": 16
  }
]

Uploading a screenshot

URL: usermedia.transifex.com/organizations/<organization_slug>/projects/<project_slug>/context/screenshots/

POST

The request is used to upload a screenshot to a project.

Example:

curl -i --user api:<token> -XPOST https://usermedia.transifex.com/organizations/transifex/projects/transifex/context/screenshots/ -v -F screenshot=@/Users/Thomas/homepage.png
HTTP/1.0 200 OK
...
{
    "id": 94376,        
    "name": "Home page",
    "media_url": "https://s3-eu-west-1.amazonaws.com/transifex-context/transifex/transifex/1cb3ff6c-65fa-4a41-8384-4eacaed7da3d_original",
    "thumb_url": "https://s3-eu-west-1.amazonaws.com/transifex-context/transifex/transifex/1cb3ff6c-65fa-4a41-8384-4eacaed7da3d_resized",
    "created": "2017-02-28T20:25:18.195987Z",
    "modified": "2017-02-28T20:25:18.196013Z",
    "created_by": "diegobz",
    "mapped_strings_count": 0
 }

Getting screenshot details

URL: api.transifex.com/organizations/<organization_slug>/projects/<project_slug>/context/screenshots/<screenshot_id>/

GET

This request is used to get information about a screenshot.

Example:

curl -i --user api:<token> -X GET https://api.transifex.com/organizations/transifex/projects/transifex/context/screenshots/94376/

HTTP/1.0 200 OK
...
{
    "id": 94376,        
    "name": "Home page",
    "media_url": "https://s3-eu-west-1.amazonaws.com/transifex-context/transifex/transifex/1cb3ff6c-65fa-4a41-8384-4eacaed7da3d_original",
    "thumb_url": "https://s3-eu-west-1.amazonaws.com/transifex-context/transifex/transifex/1cb3ff6c-65fa-4a41-8384-4eacaed7da3d_resized",
    "created": "2017-02-28T20:25:18.195987Z",
    "modified": "2017-02-28T20:25:18.196013Z",
    "created_by": "diegobz",
    "mapped_strings_count": 4
 }

Updating a screenshot

URL: usermedia.transifex.com/organizations/<organization_slug>/projects/<project_slug>/context/screenshots/<screenshot_id>/

PATCH

This request is used to rename a screenshot or update the screenshot itself.

The allowed parameters are:

  • name - the new name of the screenshot
  • screenshot - the new screenshot

Example:

curl --user api:<token> -XPATCH https://usermedia.transifex.com/organizations/transifex/projects/transifex/context/screenshots/94376/ -v -F name="New home page"
HTTP/1.0 200 OK
...
{
    "id": 94376,        
    "name": "New home page",
    "media_url": "https://s3-eu-west-1.amazonaws.com/transifex-context/transifex/transifex/1cb3ff6c-65fa-4a41-8384-4eacaed7da3d_original",
    "thumb_url": "https://s3-eu-west-1.amazonaws.com/transifex-context/transifex/transifex/1cb3ff6c-65fa-4a41-8384-4eacaed7da3d_resized",
    "created": "2017-02-28T20:25:18.195987Z",
    "modified": "2017-02-28T20:25:18.196013Z",
    "created_by": "diegobz",
    "mapped_strings_count": 0
 }

Deleting a screenshot

URL: api.transifex.com/organizations/<organization_slug>/projects/<project_slug>/context/screenshots/<screenshot_id>/

DELETE

This request is used to delete a screenshot from a project.

Example:

curl -i --user api:<token> -X DELETE https://api.transifex.com/organizations/transifex/projects/tests-2/context/screenshots/95311/

HTTP/1.1 204 No Content

Getting a list of mapped strings

URL: api.transifex.com/organizations/<organization_slug>/projects/<project_slug>/context/screenshots/<screenshot_id>/mapped_strings/

GET

This request is used to get all the mapped strings for a screenshot.

The response is a JSON list of strings mapped to the screenshot. For each mapped string, there is a dictionary with the following data:

  • source_string_hash - the hash of the source string (learn how to calculate it here)
  • resource_slug - the slug of the resource
  • coordinates - coordinates of the position of the string from the top left corner and dimensions of the container area ({} if the string is not mapped to a specific position):
    • x
    • y
    • width
    • height
  • source_string - the source string
  • id - the id of the mapping

Example:

curl -i --user api:<token> -X GET https://api.transifex.com/organizations/transifex/projects/tests-2/context/screenshots/95311/mapped_strings/

HTTP/1.1 200 OK
[
    {
        "source_string_hash":"701f39eae5ddd8534d42ef50209851ca",    
        "resource_slug":"my resource slug",
        "coordinates":
        {
            "width":372,
            "x":423,
            "height":59,
            "y":261
        },
        "source_string":"a source string example",
        "id":6555
    },
    {
        "source_string_hash":"5ec107918ccee4bed1b65f7cd02ffd83",
        "resource_slug":"my resource slug",
        "coordinates":
        {
            "width":372,
            "x":36,
            "height":25,
            "y":116
        },
        "source_string":"another source string",
        "id":6554
    }
]

Mapping strings to a screenshot

URL: api.transifex.com/organizations/<organization_slug>/projects/<project_slug>/context/screenshots/<screenshot_id>/mapped_strings/

POST

This request is used to map one or more strings to a screenshot. Note that while the coordinates attribute is required, you can leave the dictionary empty if you don't want to map a string to a specific position in the screenshot.

Example:

curl -i --user api:<token> -X POST https://api.transifex.com/organizations/transifex/projects/tests-2/context/screenshots/95311/mapped_strings/ -v -H "Content-Type: application/json" --data '[{"coordinates": {"height": 50, "width": 30, "x": 10, "y": 20}, "resource_slug": "a_resource_slug", "source_string_hash": "my_hash"}, {"coordinates": {}, "resource_slug": "a_resource_slug", "source_string_hash": "my_second_hash"}]'

HTTP/1.1 201 Created

[
    {
        "source_string_hash":"my_hash",
        "resource_slug":"a_resource_slug",
        "coordinates":
        {
            "width":30,
            "x":10,
            "height":50,
            "y":20
        },
        "source_string":"my source string",
        "id":6561
    },
    {
        "source_string_hash":"my_second_hash",
        "resource_slug":"a_resource_slug",
        "coordinates":{},
        "source_string":"another source string",
        "id":6562
    }
]

Unmapping strings from screenshot

URL: api.transifex.comorganizations/<organization_slug>/projects/<project_slug>/context/screenshots/<screenshot_id>/mapped_strings/ 

DELETE

This request is used to unmap all strings from a screenshot.

Example:

curl -i --user api:<token> -X DELETE https://api.transifex.com/organizations/transifex/projects/tests-2/context/screenshots/95311/mapped_strings/

HTTP/1.1 204 No Content

Unmapping a single string

URL: https://api.transifex.com/organizations/projects/context/screenshots/mapped_strings/

DELETE

This request is used to unmap a specific string from a screenshot.

Example:

curl -i --user api:<token> -X DELETE https://api.transifex.com/organizations/transifex/projects/tests-2/context/screenshots/95311/mapped_strings/1234/

HTTP/1.1 204 No Content