Links
Comment on page
🧍

Check Single User

Learn how to use Airstack to check if a single user has XMTP or not.

🧍 Check Single User

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

  • An Airstack account (free)
  • Basic knowledge of GraphQL
  • Basic knowledge of XMTP

Get Started

JavaScript/TypeScript/Python
If you are using JavaScript/TypeScript or Python, Install the Airstack SDK:
npm
yarn
pnpm
pip
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
pip install airstack
Then, add the following snippets to your code:
React
Node
Python
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.

🤖 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.
Airstack AI (Demo)

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

https://app.airstack.xyz/query/ZT1QLdVkIx
Check Single User Has XMTP With 0x Address (Demo)

Code

Query
Response
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

https://app.airstack.xyz/query/6oVZYGDzXG
Check Single User Does Not Have XMTP With 0x Address (Demo)

Code

Query
Response
query MyQuery {
XMTPs(
input: {
blockchain: ALL
filter: { owner: { _eq: "0x5416e5dc14caa0950b2a24ede1eb0e97c360bcf5" } }
}
) {
XMTP {
isXMTPEnabled
}
}
}
{
"data": {
"XMTPs": {
"XMTP": null
}
}
}

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

https://app.airstack.xyz/query/1n0kL621qf
Check Single User Has XMTP With ENS (Demo)

Code

Query
Response
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

https://app.airstack.xyz/query/jr6QAbmRGb
Show me if yosephks.cb.id has XMTP enabled or not

Code

Query
Response
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

https://app.airstack.xyz/query/ngQHil80AU
Check Single User Has XMTP With Lens Profile Name (Demo)

Code

Query
Response
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 decimal or hex form:

Try Demo

https://app.airstack.xyz/query/QO9CcBlwQY
Check Single User Has XMTP With Lens Profile ID (Demo)

Code

Query
Response
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 Farcaster Name:

Try Demo

https://app.airstack.xyz/query/ju22glZstP
Check Single User Has XMTP With Farcaster Name (Demo)

Code

Query
Response
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

https://app.airstack.xyz/query/g2m7nSXVBQ
Check Single User Has XMTP With Farcaster ID (Demo)

Code

Query
Response
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 web3 identities, please join our Airstack's Telegram group.

More Resources

  1. 1.
    e.g. lens/@vitalik
  2. 2.
    e.g. lens_id:0x19af