๐งCheck Single User
Learn 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:
React
npm install @airstack/airstack-react
Node
npm install @airstack/node
React
yarn add @airstack/airstack-react
Node
yarn add @airstack/node
React
pnpm install @airstack/airstack-react
Node
pnpm install @airstack/node
Then, add the following snippets to your code:
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>;
}
};
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);
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.
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 MyQuery {
XMTPs(
input: {
blockchain: ALL
filter: { owner: { _eq: "0xa91c2d10a993d14f842d23b97f2ab3fdf6b5b9aa" } }
}
) {
XMTP {
isXMTPEnabled
}
}
}
{
"data": {
"XMTPs": {
"XMTP": [
{
"isXMTPEnabled": true
}
]
}
}
}
Here's an example of user the does not have any XMTP:
Try Demo
Code
query MyQuery {
XMTPs(
input: {
blockchain: ALL
filter: { owner: { _eq: "0x5416e5dc14caa0950b2a24ede1eb0e97c360bcf5" } }
}
) {
XMTP {
isXMTPEnabled
}
}
}
{
"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 MyQuery {
XMTPs(
input: {
blockchain: ALL
filter: { owner: { _eq: "GJQUFnCu7ZJHxtxeaeskjnqyx8QFAN1PsiGuShDMPsqV" } }
}
) {
XMTP {
isXMTPEnabled
}
}
}
{
"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. ):
Try Demo
Code
query MyQuery {
XMTPs(input: { blockchain: ALL, filter: { owner: { _eq: "vitalik.eth" } } }) {
XMTP {
isXMTPEnabled
}
}
}
{
"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 MyQuery {
XMTPs(
input: { blockchain: ALL, filter: { owner: { _eq: "yosephks.cb.id" } } }
) {
XMTP {
isXMTPEnabled
}
}
}
{
"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 MyQuery {
XMTPs(
input: { blockchain: ALL, filter: { owner: { _eq: "lens/@vitalik" } } }
) {
XMTP {
isXMTPEnabled
}
}
}
{
"data": {
"XMTPs": {
"XMTP": [
{
"isXMTPEnabled": true
}
]
}
}
}
Alternatively, you can also swap the address input owner
to any Lens profile ID, either in or hex form:
Try Demo
Code
query MyQuery {
XMTPs(
input: { blockchain: ALL, filter: { owner: { _eq: "lens_id:100275" } } }
) {
XMTP {
isXMTPEnabled
}
}
}
{
"data": {
"XMTPs": {
"XMTP": [
{
"isXMTPEnabled": true
}
]
}
}
}
By Farcaster Name or ID
With Airstack Identity API, you can simply swap the address input owner
to any :
Try Demo
Code
query MyQuery {
XMTPs(
input: {
blockchain: ALL
filter: { owner: { _eq: "fc_fname:vitalik.eth" } }
}
) {
XMTP {
isXMTPEnabled
}
}
}
{
"data": {
"XMTPs": {
"XMTP": [
{
"isXMTPEnabled": true
}
]
}
}
}
Alternatively, you can also swap the address input owner
to any Farcaster ID:
Try Demo
Code
query MyQuery {
XMTPs(input: { blockchain: ALL, filter: { owner: { _eq: "fc_fid:5650" } } }) {
XMTP {
isXMTPEnabled
}
}
}
{
"data": {
"XMTPs": {
"XMTP": [
{
"isXMTPEnabled": true
}
]
}
}
}
Developer Support
If you have any questions or need help regarding checking XMTP for a single user with various , please join our Airstack's Telegram group.
More Resources