Skip to main content

Playgrounds

Playgrounds are interactive environments where you can test and explore our GraphQL API in real-time. Whether you're experimenting with queries or debugging responses, playgrounds provide a user-friendly interface to help you get the most out of our API.

Those already familiar with GraphQL may appreciate our in-house OneSource Playground, while those new to GraphQL are likely to find Apollo Sandbox to be more helpful.

OneSource Playground

Key Features

  • Autocomplete & Validation: Get suggestions and error messages as you type, ensuring your requests are correct.
  • Query Templates: The playground is preloaded with a selection of query templates to get you started right away.
  • Pre-configured for OneSource: Our Ethereum endpoint is pre-configured so that you can simply input your API key upon page load and start playing.

Accessing the Playground

To access the OneSource Playground:

  1. Login to your OneSource account and copy your API key value (BP-{KEYVALUE} only).
  2. Navigate your browser to playground.onesource.io.
  3. Paste your API key value into the prompt that appears upon loading the playground and push 'OK'.
OneSource Playground Enter API Key
note

You must have an active API key to use the playground. If you don't have one, refer to Get an API Key for information on how to get one.

Should you make a mistake when pasting your API key value into the prompt, navigate to the playground settings via the gear wheel icon in the upper right and correct your API key value.

OneSource Playground Settings

Using the Playground

Execute the Preloaded Queries

The playground is preloaded with three query templates with query variables ready to execute:

  1. Get Token: Retrieves data pertaining to a particular ERC-721 token.
  2. Get Token with Image: Retrieves data and images pertaining to a particular ERC-721 token.
  3. Get Owner by Balances by Contract: Retrieves balances data pertaining to a particular ERC-721 token for a specific wallet address.

Get started with the playground by executing the preloaded query templates with query variables using the play button in the middle of the interface and evaluating the responses that appear in the right panel.

OneSource Playground Customize Preloaded Query

Customize Preloaded Query Variables

Try replacing the query variables with variables more relevant to your interests or project and executing the queries again.

OneSource Playground Preloaded Query

Write a Custom Query

To begin writing a custom query, click the + button to open a new tab.

OneSource Playground Custom Query

For guidance on how to write and structure a custom query, refer to the OneSource Web3 API Reference. You may also refer to the DOCS and SCHEMA tabs on the right side of the playground for reference when writing custom queries.

OneSource Playground Docs/Schema Tabs

History

The playground saves every query that you run throughout your session. Click the HISTORY button to view and revert back to previously executed queries from your current session.

OneSource Playground History

You can STAR specific queries to make them easier to find in your session history.


Apollo Sandbox

Key Features

  • Interactive Query Builder: Build queries by selecting arguments and fields from the schema documentation.
  • Comprehensive Documentation: Auto-generated documentation for all types and queries including field descriptions.
  • Debugging Tools: Pretty-printed JSON results with collapsible sections and detailed error messages with path highlighting.

Accessing Apollo Sandbox

This link loads Apollo Sandbox pre-configured with the OneSource Web3 API Ethereum endpoint and header key.

Simply replace BP-{KEYVALUE} in the Headers tab with your API key value (BP-{KEYVALUE} only) and you're ready to begin.

Apollo Sandbox Playground

Using Apollo Sandbox

Although the above link to Apollo Sandbox is not pre-configured with query templates like the OneSource Playground, it is quite easy to build your own queries with the Apollo Sandbox interactive query builder.

Below is how you would select arguments and fields to recreate the Get ERC-20 Token Details example query below.

Apollo Sandbox Playground Query Build

warning

It is important to note that Apollo Sandbox by default polls the connected endpoint for schema changes every 5 seconds. Each poll is counted by OneSource as a request against your API key. You may wish to disable this feature so as to conserve your requests, particularly if you intend to be working with the Apollo Sandbox for extended periods of time.

This setting can be disabled by navigating to the settings where you can edit the Connection settings. In the Connection settings menu, toggle the Auto Update feature to the OFF position as shown below.

Apollo Sandbox Playground Connection Settings

Other Features

Apollo Sandbox allows you to retain and reference your history and browse the schema just like the OneSource Playground. You can access these features as shown below.

Apollo Sandbox Playground Other Features

Example Queries

Here are some example query templates you can use on any playground as you get acquainted with OneSource. Please refer to the OneSource Web3 API Reference for more comprehensive documentation of all available queries.

Get ERC-20 Token Details

This query fetches all available data about a given ERC-20 token contract.

query Contract($contractId: ID!) {
contract(id: $contractId) {
id
type
name
symbol
decimals
createdAt
createdBlock
holders
}
}

Variables

{
"contractId": "contract-address-here"
}

Get NFT Token Details

This query fetches the name, description, medium thumbnail image, and contract address and type of a given NFT token.

query Token($contract: ID!, $tokenID: ID!) {
token(contract: $contract, tokenID: $tokenID) {
name
description
image {
thumbnails(where: { preset: MEDIUM }) {
url
}
}
contract {
id
isERC721
isERC1155
}
}
}

Variables

{
"contract": "NFT-contract-address-here",
"tokenID": "123"
}

Get NFT Token Details With Image

This query fetches the name, symbol, and type of an NFT contract as well as its token URI and every available media thumbnail size with dimensions and type of each.

query GetTokenWithImage(
$contract: ID!
$tokenID: ID!
) {
token(
contract: $contract
tokenID: $tokenID
) {
contract {
id
type
name
symbol
decimals
}
tokenID
tokenURI
tokenURIStatus
image {
status
url
contentType
width
height
thumbnails {
preset
status
url
width
height
contentType
createdAt
}
createdAt
errorMsg
}
createdAt
createdBlock
}
}

Variables

{
"contract": "NFT-contract-address-here",
"tokenID": "123"
}

Get Wallet Token Balance

This query fetches a wallet's balance of a given ERC-20 token contract as well as the ERC-20 token contract's name, symbol and type. This query could be amended for an ERC-721 or ERC-1155 token by adding the tokenID argument to the query and variables.

query Balance($owner: ID!, $contract: ID!) {
balance(owner: $owner, contract: $contract) {
value
contract {
name
symbol
}
contractType
owner
}
}

Variables

{ "owner": "wallet-address-here",
"contract": "erc-20-contract-address-here"
}

Get All Tokens With Name Containing a Word

This query fetches all tokens with a name containing a word or string of characters.

query Contracts($where: ContractFilter) {
contracts(where: $where) {
contracts {
name
symbol
type
id
}
}
}

Variables

{
"where": {
"name_like": "word-here"
}
}