đ§ Check Single UserLearn how to use Airstack to check if a single user has XMTP or not.
Airstack provides easy-to-use APIs for enriching XMTP applications and integrating on-chain and off-chain data with XMTP .
Table Of Contents
In this guide you will learn how to use Airstack to check if a single user has XMTP enabled:
Pre-requisites
Basic knowledge of GraphQL
Get Started
JavaScript/TypeScript/Python
If you are using JavaScript/TypeScript or Python, Install the Airstack SDK:
npm yarn pnpm pip
React
Copy npm install @airstack/airstack-react
Node
Copy npm install @airstack/node
React
Copy yarn add @airstack/airstack-react
Node
Copy yarn add @airstack/node
React
Copy pnpm install @airstack/airstack-react
Node
Copy pnpm install @airstack/node
Then, add the following snippets to your code:
React Node Python
Copy import { init , useQuery } from "@airstack/airstack-react" ;
init ( "YOUR_AIRSTACK_API_KEY" );
const query = `YOUR_QUERY` ; // Replace with GraphQL Query
const Component = () => {
const { data , loading , error } = useQuery (query);
if (data) {
return < p >Data: { JSON .stringify (data)}</ p >;
}
if (loading) {
return < p >Loading...</ p >;
}
if (error) {
return < p >Error: { error .message}</ p >;
}
};
Copy import { init , fetchQuery } from "@airstack/node" ;
init ( "YOUR_AIRSTACK_API_KEY" );
const query = `YOUR_QUERY` ; // Replace with GraphQL Query
const { data , error } = await fetchQuery (query);
console .log ( "data:" , data);
console .log ( "error:" , error);
Copy import asyncio
from airstack . execute_query import AirstackClient
api_client = AirstackClient (api_key = "YOUR_AIRSTACK_API_KEY" )
query = """YOUR_QUERY""" # Replace with GraphQL Query
async def main ():
execute_query_client = api_client . create_execute_query_object (
query = query)
query_response = await execute_query_client . execute_query ()
print (query_response.data)
asyncio . run ( main ())
Other Programming Languages
To access the Airstack APIs in other languages, you can use https://api.airstack.xyz/gql as your GraphQL endpoint.
đ¤ AI Natural Language â Airstack provides an AI solution for you to build GraphQL queries to fulfill your use case easily. You can find the AI prompt of each query in the demo's caption or title for yourself to try.
By 0x Address
Simply use the following query to check if a user has XMTP or not with this example of a user that has an XMTP :
Try Demo
Code
Query Response
Copy query MyQuery {
XMTPs(
input: {
blockchain : ALL
filter : { owner : { _eq : "0xa91c2d10a993d14f842d23b97f2ab3fdf6b5b9aa" } }
}
) {
XMTP {
isXMTPEnabled
}
}
}
Copy {
"data" : {
"XMTPs" : {
"XMTP" : [
{
"isXMTPEnabled" : true
}
]
}
}
}
Here's an example of user the does not have any XMTP :
Try Demo
Code
Query Response
Copy query MyQuery {
XMTPs(
input: {
blockchain : ALL
filter : { owner : { _eq : "0x5416e5dc14caa0950b2a24ede1eb0e97c360bcf5" } }
}
) {
XMTP {
isXMTPEnabled
}
}
}
Copy {
"data" : {
"XMTPs" : {
"XMTP" : null
}
}
}
By Solana Address
Simply use the following query to check if a solana address has enabled XMTP or not with this example of a user that has an XMTP :
Try Demo
Code
Query Response
Copy query MyQuery {
XMTPs(
input: {
blockchain : ALL
filter : { owner : { _eq : "GJQUFnCu7ZJHxtxeaeskjnqyx8QFAN1PsiGuShDMPsqV" } }
}
) {
XMTP {
isXMTPEnabled
}
}
}
Copy {
"data" : {
"XMTPs" : {
"XMTP" : [
{
"isXMTPEnabled" : true
}
]
}
}
}
By ENS
With Airstack Identity API , you can simply swap the address input to any ENS names, either on-chain or off-chain (e.g. Namestone ):
Try Demo
Code
Query Response
Copy query MyQuery {
XMTPs(input: { blockchain : ALL, filter : { owner : { _eq : "vitalik.eth" } } }) {
XMTP {
isXMTPEnabled
}
}
}
Copy {
"data" : {
"XMTPs" : {
"XMTP" : [
{
"isXMTPEnabled" : true
}
]
}
}
}
By cb.id
With Airstack Identity API , you can simply swap the address input to any cb.id:
Try Demo
Code
Query Response
Copy query MyQuery {
XMTPs(
input: { blockchain : ALL, filter : { owner : { _eq : "yosephks.cb.id" } } }
) {
XMTP {
isXMTPEnabled
}
}
}
Copy {
"data" : {
"XMTPs" : {
"XMTP" : [
{
"isXMTPEnabled" : true
}
]
}
}
}
By Lens Profile Name or ID
With Airstack Identity API , you can simply swap the address input owner
to any Lens profile name:
Try Demo
Code
Query Response
Copy query MyQuery {
XMTPs(
input: { blockchain : ALL, filter : { owner : { _eq : "lens/@vitalik" } } }
) {
XMTP {
isXMTPEnabled
}
}
}
Copy {
"data" : {
"XMTPs" : {
"XMTP" : [
{
"isXMTPEnabled" : true
}
]
}
}
}
Alternatively, you can also swap the address input owner
to any Lens profile ID, either in decimal or hex form:
Try Demo
Code
Query Response
Copy query MyQuery {
XMTPs(
input: { blockchain : ALL, filter : { owner : { _eq : "lens_id:100275" } } }
) {
XMTP {
isXMTPEnabled
}
}
}
Copy {
"data" : {
"XMTPs" : {
"XMTP" : [
{
"isXMTPEnabled" : true
}
]
}
}
}
By Farcaster Name or ID
With Airstack Identity API , you can simply swap the address input owner
to any Farcaster Name :
Try Demo
Code
Query Response
Copy query MyQuery {
XMTPs(
input: {
blockchain : ALL
filter : { owner : { _eq : "fc_fname:vitalik.eth" } }
}
) {
XMTP {
isXMTPEnabled
}
}
}
Copy {
"data" : {
"XMTPs" : {
"XMTP" : [
{
"isXMTPEnabled" : true
}
]
}
}
}
Alternatively, you can also swap the address input owner
to any Farcaster ID:
Try Demo
Code
Query Response
Copy query MyQuery {
XMTPs(input: { blockchain : ALL, filter : { owner : { _eq : "fc_fid:5650" } } }) {
XMTP {
isXMTPEnabled
}
}
}
Copy {
"data" : {
"XMTPs" : {
"XMTP" : [
{
"isXMTPEnabled" : true
}
]
}
}
}
Developer Support
If you have any questions or need help regarding checking XMTP for a single user with various web3 identities , please join our Airstack's Telegram group.
More Resources