OpenSea GraphQL API

פרמיום
על ידי ArgusAPI2 | מְעוּדכָּן 2달 전 | Data
פּוֹפּוּלָרִיוּת

7.1 / 10

חֶבִיוֹן

452ms

רמת שירות

100%

Health Check

N/A

חזרה לכל ההדרכות (2)

How to use the Opensea GraphQL API

Opensea GraphQL API Tutorial

Video Tutorial Coming Soon

Introduction

To use this API, I recommend identifying what requests / queries you want to use beforehand. You will need a browser, and a programming language with a http networking library. (for example: Python w/ requests, Golang w/ net/http, Node w/ axios) - In this tutorial we will be working with python 3.7 and the requests module.

This tutorial assumes already you know python basics, and how the requests module works - Additionally you should know, how to use a standard browser debugger. If you do not you can read more here:
Learn Python: https://www.booksfree.org/wp-content/uploads/2022/05/Learn-Python-in-One-Day-and-Learn-It-Well-by-Jamie-Chan-pdf-free-download.pdf
Learn Requests: https://realpython.com/python-requests/
Learn chrome debugger basics: https://developer.chrome.com/docs/devtools/network/

Step 1 - Find your Opensea GraphQL query


First stage is go on Opensea while chrome debugger is recording requests and find a request you are trying to use yourself. The image above outlines things to note when capturing. Remember that the endpoint ends with /graphql, you can check the response payloads to check whether the request is correct or check the query name / id.

Step 2 - Copy the GraphQL query


Next we have to copy the query, first go to the preview section, outlined in the image above. Then click view parsed, also outlined above (no 2). Lastly copy the whole request and store it somewhere.

Step 3 - Copy the signed query


Thereafter, we need to copy one last thing which is the signed query. The signed query is constant for each query meaning it is constant for each request with the same query (You can change variables). Though if you want a new request with another query (A request which fetches a different type of data) you will need to copy the signed query for that request.

Anyways we go to headers, outlined in the image above, then scroll down to the x-signed-query header and copy the value.

Step 4 - Implementing the GraphQL request


When implementing the request, we have the be wary about sending the data correctly.
The GraphQL data should be formatted in a way so it can be sent as a valid JSON content type. (Content-Type: application/json)
The image above does this, but in python.

For headers we want to be using the following (code below is python dict formatted)):

headers = {
	"content-type": "application/json",
	"x-signed-query": "YOUR SIGNED QUERY GOES HERE",
	"x-viewer-address": "LEAVE THIS AS WHATEVER, VALUE DOES NOT MATTER BUT IT NEEDS A VALUE",
	"X-RapidAPI-Key": "YOUR RAPID API KEY",
	"X-RapidAPI-Host": "opensea-graphql-api.p.rapidapi.com"
}

x-signed-query should be your signed query from step 3.

x-viewer-address can be whatever you want, I usually set it as a random ETH address.

X-RapidAPI-Key is the API key of your RapidAPI account

X-RapidAPI-Host should always to set to “opensea-graphql-api.p.rapidapi.com