Skip to content

GraphQL query examples

Caio Almeida edited this page Oct 1, 2024 · 97 revisions

Please note that this page is a work in progress

To learn how to use the queries below, read about querying the database through Check API


This is a list of common queries performed on Check API and its responses.

For the collections (so, everytime you ask for a field that contains edges), you must specify how many items should be returned, by passing first or last. For pagination, you can also pass after, which takes the GraphQL ID of a node. For example:

project_medias(first: 10, after: "haghx6xsagh\n") {
  edges {
    node {
      (...)
    }
  }
}

Table of Contents

Get team information

Get the teams that are associated with the token used in authentication and for each team returns the name, slug id and dbid.

Query

query {
  me {
    teams {
      edges {
        node {
          name
          slug
          dbid
          id
        }
      }
    }
  }
}

Response

{
  "data": {
    "me": {
      "teams": {
        "edges": [
          {
            "node": {
              "name": "Studio Ghibli",
              "slug": "studio-ghibli",
              "dbid": 3,
              "id": "VGVhbS8z\n"
            }
          },
        ]
      }
    }
  }
}

Get team tags

Get the list of tags present on a team.

Query

query {
  team(slug: "studio-ghibli") {
    tag_texts {
      edges {
        node {
          text
        }
      }
    }
  }
}

Response

{
  "data": {
    "team": {
      "tag_texts": {
        "edges": [
          {
            "node": {
              "text": "character"
            }
          },
          {
            "node": {
              "text": "movie"
            }
          },
          {
            "node": {
              "text": "music"
            }
          }
        ]
      }
    }
  }
}

Get list of status of a team

In the example below we get all the possible status of a team. We also pass verified to items_count and published_reports_count, it returns the numbers of items and published reports with the status verified. If you don't care about the numbers of a specific status, you can just pass verification_statuses(), without items_count and published_reports_count.

Query

query {
  team(slug: "studio-ghibli") {
    verification_statuses(items_count_for_status: "verified", 
      published_reports_count_for_status: "verified")
  }
}

Response

{
  "data": {
    "team": {
      "verification_statuses": {
        "active": "in_progress",
        "default": "undetermined",
        "label": "Status",
        "statuses": [
          {
            "id": "in_progress",
            "label": "Em Progresso",
            "locales": {
              "en": {
                "description": "",
                "label": "In Progress",
                "message": "We started looking into that!"
              },
              "fr": {
                "description": "",
                "label": "en cours"
              },
              "pt": {
                "description": "",
                "label": "Em Progresso",
                "message": "Começamos a investigar isso!"
              }
            },
            "should_send_message": true,
            "style": {
              "color": "#ff864d"
            }
          },
          {
            "id": "verified",
            "label": "Verdadeiro",
            "locales": {
              "en": {
                "description": "",
                "label": "True"
              },
              "fr": {
                "description": "",
                "label": "Vrai"
              },
              "pt": {
                "description": "",
                "label": "Verdadeiro",
                "message": ""
              }
            },
            "should_send_message": false,
            "style": {
              "color": "#41b070"
            }
          },
          {
            "id": "misleading",
            "label": "Enganoso",
            "locales": {
              "en": {
                "description": "",
                "label": "Misleading"
              },
              "fr": {
                "description": "",
                "label": "Fallacieux"
              },
              "pt": {
                "description": "",
                "label": "Enganoso",
                "message": ""
              }
            },
            "style": {
              "backgroundColor": "#fc52ff",
              "borderColor": "#fc52ff",
              "color": "#fc52ff"
            },
            "published_reports_count": 75,
            "items_count": 219
          }
        ]
      }
    }
  }
}

Create a project in a team

Using the team dbid from the first query as id, you can create a project under a team.

Query

mutation {
  createProject(input: {
    clientMutationId: "1",
    title: "The Cat Returns",
    team_id: 3
  }) {
    project {
      dbid
    }
  }
}

Response

{
  "data": {
    "createProject": {
      "project": {
        "dbid": 12
      }
    }
  }
}

Add new auto task to a team

Using the team id from the first query, the query below adds a new auto task to a team and gets the updated list of auto tasks as response. The type inside add_auto_task can be geolocation, datetime, free_text, single_choice, multiple_choice or image_upload. For free_text and single_choices, an additional field options should exist inside add_auto_task, which is a JSON string with format [{\"label\":\"Option A\"},{\"label\":\"Option B\"}].

Query

mutation {
 updateTeam(input: {
    clientMutationId: "1",
    id: "VGVhbS8z\n",
    add_auto_task: {
      label: "Did you watch this movie?",
      type: "single_choice",
      description: "",
      options: [{label: "Yes"},{label: "No"}],
      fieldset: "tasks"
    }
  }) {
    team {
      team_tasks {
        edges {
          node {
            label
            description
            options
            type
          }
        }
      }
    }
  }
}

Response

{
  "data": {
    "updateTeam": {
      "team": {
        "team_tasks": {
          "edges": [
            {
              "node": {
                "label": "What's the name of the movie?",
                "description": null,
                "options": [],
                "type": "free_text"
              }
            },
            {
              "node": {
                "label": "Did you watch this movie?",
                "description": "",
                "options": [
                  {
                    "label": "Yes"
                  },
                  {
                    "label": "No"
                  }
                ],
                "type": "single_choice"
              }
            }
          ]
        }
      }
    }
  }
}

Get metadata/annotations created automatically for items

The metadata/annotations created automatically when creating items are also called "team tasks". This query returns the tasks that will be created automatically when creating items in a team. The fieldset shows the type "metadata" or "tasks".

Query

query {
  team {
    team_tasks {
      edges {
        node {
          label
          fieldset
          description
          options
          type
          required
        }
      }
    }
  } 
}

Response

{
  "data": {
    "team": {
      "team_task": {
        "edges": [
          {
            "node": {
              "label": "What's the name of the movie?",
              "fieldset": "tasks",
              "description": null,
              "options": [],
              "type": "free_text",
              "required": true,
              "json_schema": null
            }
          },
          {
            "node": {
              "label": "Did you watch this movie?",
              "fieldset": "metadata",
              "description": "",
              "options": [
                {
                  "label": "Yes"
                },
                {
                  "label": "No"
                }
              ],
              "type": "single_choice",
              "required": false,
              "json_schema": null
            }
          }
       ]
    }
  }
}

Create an item

You can add a link, a claim, a picture or a video to an existent project, optionally with responses to tasks and metadata fields. When answering them, you should send the slug of the task or metadata field in order to identify it.

Create a link

Query

mutation create {
  createProjectMedia(input: {
    url: "https://en.wikipedia.org/wiki/Spirited_Away",
    clientMutationId: "1"
  }) {
    project_media {
      title
      dbid
      id
    }
  }
}

Response

{
  "data": {
    "createProjectMedia": {
      "project_media": {
        "title": "Spirited Away - Wikipedia",
        "dbid": 108,
        "id": "UHJvamVjdE1lZGlhLzEwOA==\n"
      }
    }
  }
}

Create a claim

Similar to the above.

Query

mutation create {
  createProjectMedia(input: {
    quote: "Once you've met someone you never really forget them. It just takes a while for your memories to return.",
    clientMutationId: "1"
  }) {
    project_media {
      title
      dbid
      id
    }
  }
}

Response

{
  "data": {
    "createProjectMedia": {
      "project_media": {
        "title": "Once you've met someone you never really forget them. It just takes a while for your memories to return.",
        "dbid": 107,
        "id": "UHJvamVjdE1lZGlhLzEwNw==\n"
      }
    }
  }
}

Python implementation

import requests
import json

text = "Text for the item 🎉"

mutation="""mutation create {
                  createProjectMedia(input: {
                    quote: """ + json.dumps(text, ensure_ascii=False) + """
                 }) {
                    project_media {
                      id
                      dbid
                    }
                  }
                }"""
req = requests.request("POST",
        "https://check-api.checkmedia.org/api/graphql",
        headers={
            "X-Check-Token": "<TOKEN>",
            "X-Check-Team": "<WORKSPACE_SLUG>",
        },
        data = {"query": mutation}
    )
print(req.text)

Create a link and set tags and status

This is similar to create a link above, but adding set_tags and set_status to the input. You can also add these fields when you create a claim to create a claim with tags and a status.

  • set_tags expects an array of strings
  • set_status expects a string that matches the id of one of your statuses. By default these are one of undetermined, in_progress, not_applicable, false, and verified, but you may have custom statuses defined in your workspace. To learn their IDs you can follow these instructions

Query

mutation create {
  createProjectMedia(input: {
    url: "https://en.wikipedia.org/wiki/Spirited_Away",
    clientMutationId: "1",
    set_tags: ["movie", "animation"], # Array of strings (optional)
    set_status: "in_progress", # One of the statuses supported by the workspace (the identifier, not the label) (optional)
  }) {
    project_media {
      title
      dbid
      id
      tags {
        edges {
          node {
            id
            tag_text
          }
        }
      }
      status
    }
  }
}

Response

{
  "data": {
    "createProjectMedia": {
      "project_media": {
        "title": "Spirited Away - Wikipedia",
        "dbid": 108,
        "id": "UHJvamVjdE1lZGlhLzEwOA==\n"
        "tags": {
          "edges": [
            {
              "node": {
                "id": "VGFnLzI5NDA=\n",
                "tag_text": "movie"
              }
            },
            {
              "node": {
                "id": "VGFnLzI5Mzk=\n",
                "tag_text": "animation"
              }
            }
          ]
        },
        "status": "in_progress"
      }
    }
  }
}

Create a link and answer team tasks

The example below creates an item and answers some team tasks. The format to send the tasks response is set_tasks_responses = { task_slug (string) => response (string) }, where:

Query

mutation create {
  createProjectMedia(input: {
    url: "https://en.wikipedia.org/wiki/Spirited_Away",
    clientMutationId: "1",
    set_tasks_responses: "{ \"what_s_the_name_of_the_movie\": \"Spirited Away\", \"did_you_watch_this_movie\": \"Yes\" }"
  }) {
    project_media {
      title
      dbid
      id
    }
  }
}

Response

{
  "data": {
    "createProjectMedia": {
      "project_media": {
        "title": "Spirited Away - Wikipedia",
        "dbid": 108,
        "id": "UHJvamVjdE1lZGlhLzEwOA==\n"
      }
    }
  }
}

Create an image or video

We can’t upload files through our graphiQL client, but you can do that by using a tool like postman, curl, among other options.

Here we have an example of how to create an item with an uploaded image and one with video using curl.

curl \
-H 'X-Check-Token: <your_token>' \
-H 'X-Check-Team: <your_check_workspace_slug>' \
-F query='mutation create { createProjectMedia(input: { media_type: "UploadedImage" }) { project_media { id dbid } } }' \
-F file=@/path/your_file.png \
"https://check-api.checkmedia.org/api/graphql"
curl \
-H 'X-Check-Token: <your_token>' \
-H 'X-Check-Team: <your_check_workspace_slug>' \
-F query='mutation create { createProjectMedia(input: { media_type: "UploadedVideo" }) { project_media { id dbid } } }' \
-F file=@/path/your_file.mp4 \
"https://check-api.checkmedia.org/api/graphql"

Python implementation

import requests
media=open("chair-20-sd-bar.mp4","rb").read()

mutation="""mutation create {
                  createProjectMedia(input: {
                    media_type: "UploadedVideo"
                 }) {
                    project_media {
                      id
                      dbid
                    }
                  }
                }"""
req = requests.request("POST",
        "https://check-api.checkmedia.org/api/graphql",
        headers={
            "X-Check-Token": "<TOKEN>",
            "X-Check-Team": "<WORKSPACE_SLUG>",
        },
        data = {"query": mutation},
        files = {"file": ("chair-20-sd-bar.mp4", media, "video/mp4")}
    )
print(req.text)

Update an item

Send an item to trash or restore it

It's possible to send or restore a single trashed item using the mutation to update an item. An item is in the trash when the attribute archived is true. If you want to send the items to trash, the mutation must include archived: 1. If the goal is to restore the items from trash, must include archived: 0.

Query

mutation {
  updateProjectMedia(input: {
    clientMutationId: "1",
    id: "UHJvamVjdE1lZGlhLzEwOA==\n",
    archived: 1
  }) { affectedId }
}

Response

{
  "data": {
    "updateProjectMedia": {
      "affectedId": "UHJvamVjdE1lZGlhLzEwOA==\n"
    }
  }
}

Bulk send items to trash or restore them

It's also possible to bulk send or restore trashed items using the mutation to update an item. An item is in the trash when the attribute "archived" is true. If you want to send the items to trash, the mutation must include "archived": 1. If the goal is to restore the items from trash, must include "archived": 0.

Query

mutation { 
	updateProjectMedias(input: { 
		clientMutationId: "1", 
		ids: [ "UHJvamVjdE1lZGlhLzI0MDI=\n", "UHJvamVjdE1lZGlhLzI0MDE=\n", "UHJvamVjdE1lZGlhLzI0MDQ=\n"],
		action: "archived", params: "{\"archived\": 1}" 
  }) { ids, team { dbid } } 
}

Response

{
  "data": {
    "updateProjectMedias": {
      "ids": [
        "UHJvamVjdE1lZGlhLzI0MDI=\n",
        "UHJvamVjdE1lZGlhLzI0MDE=\n",
        "UHJvamVjdE1lZGlhLzI0MDQ=\n"
      ],
      "team": {
        "dbid": 3
      }
    }
  }
}

Customize title and description if an item

To customize the title and description displayed on analysis sidebar and report you'll need the id of the project_media's last_status_obj. Check Get status details of an item to know how to get the id. The title and description are saved as annotation fields. Please note the set_fields field should be sent in JSON string format.

The example below shows how to add a customized title and description on item that has the status with the id sent on input.

Query

mutation {
  updateDynamic(input: {
    id: "RHluYW1pYy83MDE1NTY1\n",
    set_fields: "{ \"title\": \"Spirited Away\", \"content\": \"A 2001 Japanese animated fantasy film\" }"
    clientMutationId: "1"
  }) {
    project_media {
      title
      description
    }
  }
}

Response

{
  "data": {
    "updateDynamic": {
      "project_media": {
        "description": "A 2001 Japanese animated fantasy film",
        "title": "Spirited Away"
      }
    }
  }
}

Update verification status of an item

To update the verification status of an item, e.g: from in progress to verified. You will need to update the Dynamic Annotation. To do that, you will need it's id. Then you will be able to use that id to update the verification status. In the example below, "147" is the item ID, while "52" is the team ID. "0" is hard-coded for legacy reasons - it used to be the folder ID.

Query

query {
  project_media(ids: "147,0,52"){
    dynamic_annotation_verification_status {
      id
    }
  }
}

Response

{
  "data": {
    "project_media": {
      "dynamic_annotation_verification_status": {
        "id": "RHluYW1pYy80ODY=\n"
      }
    }
  }
}

Query

mutation {
  updateDynamic(input: {
    id: "RHluYW1pYy80ODY=\n"
    set_fields: "{\"verification_status_status\":\"verified\"}"
  }) {
    project_media {
      dbid,
      id,
      last_status
    }
  }
}

Response

{
  "data": {
    "updateDynamic": {
      "project_media": {
        "id": "UHJvamVjdE1lZGlhLzE0Nw==\n",
        "dbid": 147,
        "last_status": "verified"
      }
    }
  }
}

Get data from items

List items of a team

With the slug or the dbid of a team you can get the projects and the data from project medias.

Query

query {
  team(id: 3) {
    name
    projects_count
    projects(last: 3) {
      edges {
        node {
          title
          project_medias(first: 1) {
            edges {
              node {
                type
                title
                picture
              }
            }
          }
        }
      }
    }
  }
}

Response

{
  "data": {
    "team": {
      "name": "Studio Ghibli",
      "projects_count": 6,
      "projects": {
        "edges": [
          {
            "node": {
              "title": "Spirited Away",
              "project_medias": {
                "edges": [
                  {
                    "node": {
                      "type": "Link",
                      "title": "Slackline-Tutorial: How to take nice Leashfalls on Highlines",
                      "picture": "https://i.ytimg.com/vi/kQsrpDnOuKU/maxresdefault.jpg"
                    }
                  }
                ]
              }
            }
          },
          {
            "node": {
              "title": "The Cat Returns",
              "project_medias": {
                "edges": [
                  {
                    "node": {
                      "type": "Link",
                      "title": "The Cat Returns - Wikipedia",
                      "picture": "https://upload.wikimedia.org/wikipedia/en/8/8e/Cat_Returns.jpg"
                    }
                  }
                ]
              }
            }
          },
          {
            "node": {
              "title": "The Tale of the Princess Kaguya",
              "project_medias": {
                "edges": [
                  {
                    "node": {
                      "type": "Link",
                      "title": "The Tale of the Princess Kaguya - Wikipedia",
                      "picture": "https://upload.wikimedia.org/wikipedia/en/6/68/The_Tale_of_the_Princess_Kaguya_%28poster%29.jpg"
                    }
                  }
                ]
              }
            }
          }
        ]
      }
    }
  }
}

List items of a project

Sending the dbid of a project as id you can get the data from project medias. The query below is also returning the field archived, that has a boolean value and is true when the item is on trash and false otherwise

Query

query {
  project(id: "4") {
    title
    project_medias(first: 2) {
      edges {
        node {
          archived
          title
          media {
            picture
            url
          }
        }
      }
    }
  }
}

Response

{
  "data": {
    "project": {
      "title": "Spirited Away",
      "project_medias": {
        "edges": [
          {
            "node": {
              "archived": true,
              "title": "Spirited Away",
              "media": {
                "picture": "https://upload.wikimedia.org/wikipedia/en/d/db/Spirited_Away_Japanese_poster.png",
                "url": "https://en.wikipedia.org/wiki/Spirited_Away"
              }
            }
          },
          {
            "node": {
              "archived": false,
              "title": "Once you've met someone you never really forget them. It just takes a while for your memories to return.",
              "media": {
                "picture": "",
                "url": null
              }
            }
          }
        ]
      }
    }
  }
}

Get the tasks and responses from an item

Sending the dbid of an item as ids you can request the tasks and the responses.

Query

query {
  project_media(ids: "108") {
    tasks {
      edges {
        node {
          label
          first_response_value
        }
      }
    }
  }
}

Response

{
  "data": {
    "project_media": {
      "tasks": {
        "edges": [
          {
            "node": {
              "label": "Do you recommend this movie?",
              "first_response_value": null
            }
          },
          {
            "node": {
              "label": "What's the name of the movie?",
              "first_response_value": "Spirited Away"
            }
          },
          {
            "node": {
              "label": "Did you watch this movie?",
              "first_response_value": "Yes"
            }
          }
        ]
      }
    }
  }
}

Add a comment on an item

A comment can be added to an item sending the type ProjectMedia as annotated_type and the dbid as annotated_id

Query

mutation {
  createComment(input: {
    clientMutationId: "1",
    text: "A comment created on an item",
    annotated_id: "108",
    annotated_type: "ProjectMedia"
  }) {
    comment {
      text
    }
  }
}

Response

{
  "data": {
    "createComment": {
      "comment": {
        "text": "A comment created on an item"
      }
    }
  }
}

Get comments of an item

The comments of an item are saved as annotations and displayed in Notes tab. If you want to display the comments of an specific item, you need to send the argument ids with the dbid (database id) of the item. The example below shows how to query the item with dbid 123456 and get the comments and some details: the text added, the creation time as integer and the name of the user who added the comment.

Query

query {
  project_media(ids: "123456") {
    annotations(annotation_type: "comment") {
      edges {
        node {
          ... on Comment {
            text
            created_at
            annotator {
              user {
                name
              }
            }
          }
        }
      }
    }
  }
}

Response

{
  "data": {
    "project_media": {
      "annotations": {
        "edges": [
          {
            "node": {
              "annotator": {
                "user": {
                  "name": "Totoro"
                }
              },
              "created_at": "1596166712",
              "text": "A comment created on an item"
            }
          },
          {
            "node": {
              "annotator": {
                "user": {
                  "name": "Chihiro"
                }
              },
              "created_at": "1596166481",
              "text": "This is a very nice movie!"
            }
          }
        ]
      }
    }
  }
}

Get status details of an item

The status of an item is a dynamic annotation. This annotation has fields for the verification status and for custom title and description. To display the last status details of an specific item, you need to send the argument ids with the dbid (database id) of the item. The example below shows how to query the item with dbid 108 and get the last status id, data and content and get the title and description of the item.

Query

query {
  project_media(ids: "108") {
    last_status_obj {
      id
      data
      content
    }
    title
    description
  }
}

Response

{
  "data": {
    "project_media": {
      "last_status_obj": {
        "content": "[{\"id\":1752,\"annotation_id\":1666,\"field_name\":\"verification_status_status\",\"annotation_type\":\"verification_status\",\"field_type\":\"select\",\"value\":\"in_progress\",\"value_json\":{},\"created_at\":\"2019-03-10T12:12:55.593Z\",\"updated_at\":\"2019-03-10T12:12:55.593Z\",\"formatted_value\":\"In progress\"}]",
        "data": {
          "fields": [
            {
              "annotation_id": 1666,
              "annotation_type": "verification_status",
              "created_at": "2019-03-10T12:12:55.593Z",
              "field_name": "verification_status_status",
              "field_type": "select",
              "formatted_value": "In progress",
              "id": 6939752,
              "updated_at": "2019-03-10T12:12:55.593Z",
              "value": "in_progress",
              "value_json": {}
            }
          ],
          "indexable": "in_progress"
        },
        "id": "RHluYW1pYy83MDE1NTY1\n"
      },
      "title": "Spirited Away - Wikipedia"
      "description": "A Japanese animated fantasy film"
    }
  }
}

Bulk update status on items

Statuses are bulk updated on items using the updateProjectMedias interface. You must provide an action of a string "update_status" and an ids field that is an array of the id of each individual item you are updating (it's a long string, not the dbid which is a number). Then under params you send a JSON string of an object containing a status property whose value is a string corresponding to a status id. You can find these ids by following instructions here and looking for id under each object in the statuses array.

In the example below we are setting the status "verified" on two items.

Query

mutation {
  updateProjectMedias(input:{
    "action": "update_status",
    "clientMutationId": "1",
    "ids": [
      "UHJvamVjdE1lZGlhLzIxNA==\n", # the individual `id` for each item you wish to remove tags from (not the `dbid`)
      "UHJvamVjdE1lZGlhLzIxNQ==\n"
    ],
    "params": "{\"status\":\"verified\"}" # a JSON string of an object containing a `status` property whose value is one of the statuses supported by the workspace (the identifier, not the label)
  }) {
    updated_objects {
      dbid
      id
      status
    }
  }
}

Response

{
  "data": {
    "updateProjectMedias": {
      "updated_objects": [
        {
          "dbid": 218,
          "id": "UHJvamVjdE1lZGlhLzIxOA==\n",
          "status": "verified",
        },
        {
          "dbid": 219,
          "id": "UHJvamVjdE1lZGlhLzIxOQ==\n",
          "status": "verified",
        }
      ],
      "clientMutationId": "1"
    }
  }
}

Log details of items

On Check the log details are displayed on Timeline. When getting the data you can see the changes on field object_changes_json in JSON format.

Query

query me {
  project_media(ids: "108") {
    title
    log(last: 4) {
      edges {
        node {
          event_type
          object_changes_json
          created_at
        }
      }
    }
  }
}

Response

{
  "data": {
    "project_media": {
      "title": "Spirited Away",
      "log": {
        "edges": [
          {
            "node": {
              "event_type": "update_dynamicannotationfield",
              "object_changes_json": "{\"value\":[\"--- undetermined\\n\",\"--- verified\\n\"]}",
              "created_at": "1591989930"
            }
          },
          {
            "node": {
              "event_type": "update_projectmedia",
              "object_changes_json": "{\"archived\":[false,true]}",
              "created_at": "1591994647"
            }
          },
          {
            "node": {
              "event_type": "update_projectmedia",
              "object_changes_json": "{\"archived\":[true,false]}",
              "created_at": "1591994829"
            }
          },
          {
            "node": {
              "event_type": "update_dynamicannotationfield",
              "object_changes_json": "{\"value\":[\"--- '{\\\"title\\\":\\\"Spirited Away\\\",\\\"description\\\":\\\"A\\\"}'\\n\",\"--- '{\\\"title\\\":\\\"Spirited Away\\\",\\\"description\\\":\\\"A 2001 Japanese animated fantasy film\\n  written and directed by Hayao Miyazaki\\\"}'\\n\"],\"value_json\":[\"{\\\"title\\\":\\\"Spirited Away\\\",\\\"description\\\":\\\"A\\\"}\",\"{\\\"title\\\":\\\"Spirited Away\\\",\\\"description\\\":\\\"A 2001 Japanese animated fantasy film written and directed by Hayao Miyazaki\\\"}\"]}",
              "created_at": "1591995024"
            }
          }
        ]
      }
    }
  }
}

Get report content of an item

The report of an item is a dynamic annotation with annotation_type: report_design. The example below shows how to query the item with dbid 110 and get the report id, dbid and data and get the title and description of the item.

Query

query {
  project_media(ids: "110") {
    title
    description
    annotation(annotation_type: "report_design") {
      id
      dbid
      data
    }
  }
}

Response

{
  "data": {
    "project_media": {
      "annotation": {
        "data": {
          "first_published": "1621627340",
          "last_published": "1621627366",
          "options": [
            {
              "description": "This summer's Olympics will go ahead even if Tokyo remains in a state of a emergency, says IOC vice-president John Coates.",
              "headline": "State of emergency won't stop Games - IOC",
              "image": "https://assets.checkmedia.org/medias/f98cee0dfe2f8e7acc12d258ec478d93/picture.jpg",
              "introduction": "Regarding what you sent to us on {{query_date}}, we reached the conclusion that it is *{{status}}*.",
              "language": "en",
              "previous_published_status_label": "True",
              "status_label": "True",
              "text": "",
              "theme_color": "#41b070",
              "title": "",
              "url": "meedan.com",
              "use_introduction": true,
              "use_text_message": false,
              "use_visual_card": true,
              "visual_card_url": "https://check-api-live.s3.eu-west-1.amazonaws.com/narcissus/screenshot-bf9fa222789763ff732e1724545e6f017c3357cd.png"
            }
          ],
          "published_count": 1,
          "state": "published"
        },
        "dbid": "9161120",
        "id": "QW5ub3RhdGlvbi85MTYxMTIw\n"
      },
      "description": "This summer's Olympics will go ahead even if Tokyo remains in a state of a emergency, says IOC vice-president John Coates.",
      "title": "State of emergency won't stop Games - IOC"
    }
  }
}

Update tags on items

Add a tag to an item

A tag can be added to an item sending the type ProjectMedia as annotated_type and the dbid as annotated_id

Query

mutation {
  createTag(input:{
    clientMutationId: "1",
    tag: "character",
    annotated_id: "27",
    annotated_type: "ProjectMedia"
  }) {
    tagEdge {
      node {
        dbid
        tag
      }
    }
  }
}

Response

{
  "data": {
    "createTag": {
      "tagEdge": {
        "node": {
          "dbid": "740",
          "tag": "1"
        }
      }
    }
  }
}

Bulk add tags to items

Multiple tags can be added to multiple items by using createTags() and sending an array containing ProjectMedia as annotated_type and the dbid as annotated_id along with the tag text itself as tag. In the example below we add apple and orange to one item and orange to another item.

Query

mutation {
  createTags(input:{
    clientMutationId: "1",
    inputs: [
      {
        tag: "apple",
        annotated_id: "27",
        annotated_type: "ProjectMedia"
      },
      {
        tag: "orange",
        annotated_id: "27",
        annotated_type: "ProjectMedia"
      },
      {
        tag: "orange",
        annotated_id: "28",
        annotated_type: "ProjectMedia"
      },
    ]
  }) {
    team {
      id
    }
  }
}

Response

Note: bulk updates don't give specific responses so here we are just asking for the team id as confirmation in response. You could query for the full list of team tags or whatever else you like here.

{
  "data": {
    "createTags": {
      "team": {
        "id": "id": "VGVhbS81\n"
      }
    }
  }
}

Bulk remove tags from items

Tags are bulk removed from items using the updateProjectMedias interface. You must provide an action of a string "remove_tags" and an ids field that is an array of the id of each individual item you are updating (it's a long string, not the dbid which is a number). Then under params you send a JSON string of an object containing a tags_text property whose value is a comma-separated string of numbers. these numbers correspond to the tag field of an individual tag (rather than tag_text as you might expect). You can find the tag value for each tag by doing a query for all team tags but adding tag to the list of properties you want sent back to you (alongside text in that linked example).

In the example below we are removing tags 5 and 6 from two items.

Query

mutation {
  updateProjectMedias(input:{
    "action": "remove_tags",
    "clientMutationId": "1",
    "ids": [
      "UHJvamVjdE1lZGlhLzIxNA==\n", # the individual `id` for each item you wish to remove tags from (not the `dbid`)
      "UHJvamVjdE1lZGlhLzIxNQ==\n"
    ],
    "params": "{\"tags_text\":\"5,6\"}" # a JSON string of an object containing a `tags_text` property whose value is a comma-separated string of numbers. these numbers correspond to the `tag` field of an individual tag (rather than `tag_text`)
  }) {
    updated_objects {
      dbid
      id
      tags {
        edges {
          node {
            tag
            tag_text
          }
        }
      }
    }
  }
}

Response

{
  "data": {
    "updateProjectMedias": {
      "updated_objects": [
        {
          "dbid": 214,
          "id": "UHJvamVjdE1lZGlhLzIxNA==\n",
          "tags": {
            "edges": [
              {
                "node": {
                  "tag": "1",
                  "tag_text": "apple"
                }
              },
              {
                "node": {
                  "tag": "2",
                  "tag_text": "orange"
                }
              }
            ]
          }
        },
        {
          "dbid": 215,
          "id": "UHJvamVjdE1lZGlhLzIxNQ==\n",
          "tags": {
            "edges": [
              {
                "node": {
                  "tag": "1",
                  "tag_text": "apple"
                }
              }
            ]
          }
        }
      ],
      "clientMutationId": "1"
    }
  }
}

Add related item

Items can be listed as secondary items of other items by adding them as related. In order to add a related item, you'll need the id of the child item and the dbid of the parent item, that should be sent as related_to_id.

Query

mutation {
  updateProjectMedia(input:{
    clientMutationId: "1",
    id:"UHJvamVjdE1lZGlhLzEwNw==\n",
    related_to_id: 26
  }) {
    related_to {
      dbid
      title
    }
  }
}

Response

{
  "data": {
    "updateProjectMedia": {
      "related_to": {
        "dbid": 26,
        "title": "Zeniba"
      }
    }
  }
}

List teams a user is related to

A team_user is a relation between a Team and a User on Check. On the example below, we get the list of team a user is related to and some fields: the id (used to update the relation), the team's name, the role and status the user has on the team.

Query

query {
  me {
    team_users {
      edges {
        node {
          id
          team {
            name
          }
          role
          status
        }
      }
    }
  }
}

Response

{
  "data": {
    "me": {
      "team_users": {
        "edges": [
          {
            "node": {
              "id": "VGVhbVVzZXIvNjQ=\n",
              "role": "journalist",
              "status": "banned",
              "team": {
                "name": "Aardman Animations"
              }
            }
          },
          {
            "node": {
              "id": "VGVhbVVzZXIvMTA4OA==\n",
              "role": "contributor",
              "status": "member",
              "team": {
                "name": "Laika"
              }
            }
          },
          {
            "node": {
              "id": "VGVhbVVzZXIvOTU4\n",
              "role": "owner",
              "status": "member",
              "team": {
                "name": "Blue Sky Studios"
              }
            }
          },
          {
            "node": {
              "id": "VGVhbVVzZXIvNDMzMg==\n",
              "role": "editor",
              "status": "member",
              "team": {
                "name": "Studio Ghibli"
              }
            }
          }
        ]
      }
    }
  }
}

Get medias, requests, fact-checks

Query

query {
  search(query: "{\"channels\":[\"any_tipline\"],\"eslimit\":50,\"esoffset\":0}") { # Change eslimit and esoffset in order to paginate
    number_of_results
    medias {
      edges {
        node {
          id
          last_status
          requests { # Tipline requests
            edges {
              node {
                id
                value_json
              }
            }
          }
          media { # Media attached
            id
            type
            quote # Present only if type is claim (text)
            url # Present only if type is link
            file_path # Present only if type is an uploaded audio, image or video
          }
          claim_description {
            description # The claim being fact-checked
            fact_check { # The fact-check
              id
              title
              summary
              url
            }
          }
        }
      }
    }
  }
}

Get medias created in a month, their tipline requests and when they were requested x responded

Query

query {
  search(query: "{\"eslimit\":10000,\"range\":{\"created_at\":{\"start_time\":\"2024-09-01T00:00:00.000Z\",\"end_time\":\"2024-10-01T00:00:00.000Z\"}}}") {
    medias(first: 10000) {
      edges {
        node {
          full_url
          requests(first: 10000, includeChildren: true) {
            edges {
              node {
                dbid
                created_at
                responded_at
              }
            }
          }
        }
      }
    }
  }
}

Get imported fact-checks

Query

query {
    search(query: "{\"esoffset\":0,\"eslimit\":100,\"channels\":[\"1\"]}") {
      number_of_results
      medias {
        edges {
          node {
            id
            claim_description {
              fact_check {
                id
                url
              }
            }
          }
        }
      }
    }
  }

Create fact-check

Create fact-check not related to any media

Create a fact-check not related to any media, but with a claim, tags, status and the fact-check itself.

Query

mutation create {
  createProjectMedia(input: {
    media_type: "Blank", # To be used when there is no media... if there is a media, replace this by either "url" (for link media) or "quote" (for text media)... when "url" is present, creation takes longer because it's going to be parsed
    channel: { main: 1 }, # This will make this item be listed under "Imported reports"
    set_tags: ["science", "astronomy"], # Array of strings (optional)
    set_status: "verified", # One of the statuses supported by the workspace (the identifier, not the label) (optional)
    set_claim_description: "Earth is round.",
    set_fact_check: {
      title: "TRUE: The Earth is round",
      summary: "Scientific evidences show that the Earth is round.",
      url: "https://en.wikipedia.org/wiki/Earth",
      language: "en", # Must be the ISO-361 code of a language supported by the workspace (optional)
      publish_report: true # If `true`, it can match incoming tipline queries (optional)
    }
  }) {
    project_media {
      id # Use this ID to update the item
      full_url # Link to the created item
      claim_description {
        fact_check {
          id # Use this ID to update the fact-check
        }
      }
    }    
  }
}

Response

{
  "data": {
    "createProjectMedia": {
      "project_media": {
        "id": "The item Base 64 ID",
        "full_url": "https://checkmedia.org/slug/project/1234/media/1234",
        "claim_description": {
          "id": "The claim Base 64 ID"
          "fact_check": {
            "id": "The fact-check Base 64 ID"
          }
        }
      }
    }
  }
}

Example with cURL

#!/bin/bash

export CHECK_TOKEN="your-api-key"
export CHECK_WORKSPACE_SLUG="your-check-workspace-slug"

query=$(cat <<-END
{
  "query" : "mutation create {
               createProjectMedia(input: {
                 media_type: \"Blank\",
                 channel: { main: 1 },
                 set_tags: [\"science\", \"astronomy\"],
                 set_status: \"verified\",
                 set_claim_description: \"Earth is round.\",
                 set_fact_check: {
                   title: \"TRUE: Earth is round\",
                   summary: \"Scientific evidences show that Earth is round.\",
                   url: \"https://en.wikipedia.org/wiki/Earth\",
                   language: \"en\",
                   publish_report: true
                 }
               }) {
                 project_media {
                   id # Keep track of the item ID so you can update or delete it later
                   claim_description {
                     id # Keep track of the claim ID so you can update or delete it later
                     fact_check {
                       id # Keep track of the fact-check ID so you can update or delete it later
                     }
                   }
                 }
               }
             }"
}
END
)
echo $query > query.json

curl -X POST \
     -H "X-Check-Token: $CHECK_TOKEN" \
     -H "Content-Type: application/json" \
     -H "X-Check-Team: $CHECK_WORKSPACE_SLUG" \
     -d @query.json \
     "https://check-api.checkmedia.org/api/graphql"
echo

Here is how each field maps to what is displayed in the Check UI:

Fact-check API Diagram

Create fact check with attached text

When creating a fact-check that includes a text or claim, use the `quote` field to specify the text content. This is useful for highlighting specific claims or statements being fact-checked.

Query

mutation create {
  createProjectMedia(input: {
    media_type: "Claim", # Specifies that the attached media is a text (claim)
    quote: "The specific claim or statement you are fact-checking.",
    channel: { main: 1 },
    set_tags: ["tag1", "tag2"],
    set_status: "verified",
    set_claim_description: "Description of the claim.",
    set_fact_check: {
      title: "Fact-check title",
      summary: "Summary of the fact-check findings.",
      url: "URL to the full fact-check report.",
      language: "en",
      publish_report: true
    }
  }) {
    project_media {
      id
      full_url
    }    
  }
}

Create a fact-check with a link

To add a fact-check that includes a link, perhaps to an external source or article, use the url field.

Query

Copy code
mutation create {
  createProjectMedia(input: {
    media_type: "Link", # Specifies that the attached media is a link
    url: "https://example.com/the-specific-article-or-source-being-fact-checked",
    channel: { main: 1 },
    set_tags: ["tag1", "tag2"],
    set_status: "verified",
    set_claim_description: "Description of the claim related to the link.",
    set_fact_check: {
      title: "Fact-check title for the linked article",
      summary: "Summary of the fact-check findings for the linked article.",
      url: "URL to the full fact-check report.",
      language: "en",
      publish_report: true
    }
  }) {
    project_media {
      id
      full_url
    }    
  }
}

Create a fact-check with an image

When adding a fact-check that includes an image, you'll need to upload the image file. Since file uploads might not be directly supported through GraphQL mutations, you may need to use a multipart/form-data request in a tool that supports file uploads, like Postman or a custom client.

Example with cURL

curl -X POST \
     -H "X-Check-Token: your-api-token" \
     -H "X-Check-Team: your-check-workspace-slug" \
     -F query='mutation create { createProjectMedia(input: { media_type: "UploadedImage", set_status: "verified", set_claim_description: "Description of the claim related to the image.", set_fact_check: { title: "Fact-check title for the image", summary: "Summary of the fact-check findings for the image.", language: "en", publish_report: true } }) { project_media { id dbid } } }' \
-F file=@/path/to/image/file.jpg  \
"https://check-api.checkmedia.org/api/graphql"

Make sure to replace /path/to/image.jpg with the actual path to the image file you wish to upload, and fill in your API token and workspace slug. This example demonstrates how to send a file along with your GraphQL query in a multipart/form-data request, which is commonly supported by various HTTP clients and tools.

Create original claim when creating fact check

When adding a fact-check, you can use the set_original_claim field to import a URL as the original claim. This URL can be in the following formats:

  1. Video URL: This will create a video as the original claim.
  2. Audio URL: This will create an audio as the original claim.
  3. Image URL: This will create a picture/image as the original claim.
  4. Normal URL: A Link will be created as the original claim when the URL does not point to any type of media.
  5. If the value in set_original_claim is not a URL, then the original claim will be created in plain-text.
Here is an example of how to use this field:

Query

mutation {
  createProjectMedia(input: {
    set_original_claim: "https://someurl.com/somefile.mp3"
  }) {
    project_media {
      title
      type
      url
    }
  }
}

This example will create an audio as the original claim.

Update a fact-check

Query

mutation update {
  updateFactCheck(input: {
    id: "The fact-check Base 64 ID",
    title: "New fact-check title",
    summary: "New fact-check summary",
    url: "New fact-check URL",
    language: "New fact-check language"
  }) {
    fact_check {
      updated_at
    }
  }
}

Response

{
  "data": {
    "updateFactCheck": {
      "fact_check": {
        "updated_at": "1679006014"
      }
    }
  }
}

Delete a fact-check

The example below deletes a fact-check based on its ID.

Query

mutation {
  destroyFactCheck(input: {
    id: "The fact-check Base 64 ID"
  }) { deletedId }
}

Response

{
  "data": {
    "destroyFactCheck": {
      "deletedId": "The fact-check Base 64 ID"
    }
  }
}

Update a claim

Query

mutation update {
  updateClaimDescription(input: {
    id: "The claim Base 64 ID",
    description: "New claim description",
    context: "New context for the claim"
  }) {
    claim_description {
      updated_at
    }
  }
}

Response

{
  "data": {
    "updateClaimDescription": {
      "claim_description": {
        "updated_at": "1679006014"
      }
    }
  }
}

Create explainer

Query

mutation createExplainer {
  createExplainer(input: {
    title: "New explainer title",
    description: "New explainer summary",
    url: "https://explainer.url/", # Optional
    language: "en", # Must be the ISO-361 code of a language supported by the workspace (optional)
    tags: ["tag1", "tag2"] # Optional
  }) {
    explainer {
      id
    }
  }
}

Response

{
  "data": {
    "createExplainer": {
      "explainer": {
        "id": "RXhwbGFpbmVyLzEK"
      }
    }
  }
}
Clone this wiki locally