# How to call bitquery API in App Script

**URL:** <https://community.bitquery.io/t/how-to-call-bitquery-api-in-app-script/15>\
**Category:** GraphQL API\
**Tags:** closed\
**Created:** [May 13, 2021, 11:49am UTC](https://community.bitquery.io/t/how-to-call-bitquery-api-in-app-script/15 "2021-05-13T11:49:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![patrik](https://avatars.discourse-cdn.com/v4/letter/p/e9bcb4/32.png) [@patrik](https://community.bitquery.io/u/patrik)\
**Post date:** [May 13, 2021, 11:49am UTC](https://community.bitquery.io/t/how-to-call-bitquery-api-in-app-script/15/1 "2021-05-13T11:49:39Z")

</div>

Hi there!

Attached you can find and example of how to do a simple App Script request from App Script:

```

    function GET_TOKEN_TEST(token) {
      const query = `
      query{
      bitcoin{
        blocks{
          count
        }
       }
    }
    `;
    const url = "https://graphql.bitquery.io/";
    const opts = {
        method: "POST",
        headers: {
            "Content-Type": "application/json",
            "X-API-KEY": "Copy there your API key"
        },
        payload: JSON.stringify({
            query
        })
    };
    var response = UrlFetchApp.fetch(url, opts)
    var w = JSON.parse(response.getContentText());
    console.log(w)
    }

```

Enjoy!
