Integrate the Leads API
| Integration | What it does | Steps |
|---|---|---|
| Badge-scanning app | Lets exhibitors scan attendee badges at the event, with a rating and a note. | Store the API key, pick a booth, scan badges. |
| Lead export | Exports the leads of a booth and syncs them with a CRM or a CSV file. | Store the API key, pick a booth, fetch the leads. |
Code examples are available in cURL, Node.js, PHP and Python.
Before you begin
- An exhibitor API key, created in the Exhibitor Center. Send it as-is in the
Authorizationheader, with noBearerprefix. See Exhibitor authentication. - Every request is a
POSTto the Leads API endpoint:https://developer.swapcard.com/exhibitor/graphql.
Build a badge-scanning app
Build an app that lets exhibitors scan attendee badges during events.
Step 1: Store the API key
Implement a secure way to collect and store the API key of each of your users.
Never store API keys in client-side code or expose them in web applications. Always store them securely on your server.
- Create a settings or configuration page in your app.
- Provide a secure input field for the API key.
- Store the key encrypted in your database or secure storage.
- Validate the key by making a test API call, such as the
{ __typename }query shown in Exhibitor authentication.
Step 2: Let the user pick a booth
Before scanning badges, users need to select the exhibitor booth they represent. Use the myExhibitors query to retrieve all the booths the user has access to. Keep the booth id (the exhibitorId) and the event id (the eventId) for the next step.
- cURL
- Node.js
- PHP
- Python
curl -X POST \
https://developer.swapcard.com/exhibitor/graphql \
-H 'Authorization: YOUR_API_KEY_HERE' \
-H 'Content-Type: application/json' \
-d '{
"query": "query myExhibitors($cursor: CursorPaginationInput) { myExhibitors(cursor: $cursor) { pageInfo { hasNextPage endCursor } nodes { id name events { nodes { id title } } } } }",
"variables": {
"cursor": {
"first": 100
}
}
}'
const query = `
query myExhibitors($cursor: CursorPaginationInput) {
myExhibitors(cursor: $cursor) {
pageInfo {
hasNextPage
endCursor
}
nodes {
id
name
events {
nodes {
id
title
}
}
}
}
}
`;
async function getMyExhibitors(apiKey) {
const response = await fetch('https://developer.swapcard.com/exhibitor/graphql', {
method: 'POST',
headers: {
'Authorization': apiKey,
'Content-Type': 'application/json'
},
body: JSON.stringify({
query: query,
variables: {
cursor: { first: 100 }
}
})
});
return await response.json();
}
<?php
$query = '
query myExhibitors($cursor: CursorPaginationInput) {
myExhibitors(cursor: $cursor) {
pageInfo {
hasNextPage
endCursor
}
nodes {
id
name
events {
nodes {
id
title
}
}
}
}
}
';
function getMyExhibitors($apiKey) {
global $query;
$data = json_encode([
'query' => $query,
'variables' => [
'cursor' => ['first' => 100]
]
]);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://developer.swapcard.com/exhibitor/graphql');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: ' . $apiKey,
'Content-Type: application/json'
]);
$result = curl_exec($ch);
curl_close($ch);
return json_decode($result, true);
}
?>
import requests
import json
def get_my_exhibitors(api_key):
query = """
query myExhibitors($cursor: CursorPaginationInput) {
myExhibitors(cursor: $cursor) {
pageInfo {
hasNextPage
endCursor
}
nodes {
id
name
events {
nodes {
id
title
}
}
}
}
}
"""
headers = {
'Authorization': api_key,
'Content-Type': 'application/json'
}
payload = {
'query': query,
'variables': {
'cursor': {'first': 100}
}
}
response = requests.post(
'https://developer.swapcard.com/exhibitor/graphql',
headers=headers,
json=payload
)
return response.json()
{
"data": {
"myExhibitors": {
"pageInfo": {
"hasNextPage": false,
"endCursor": "eyJpZCI6IjEyMzQ1In0="
},
"nodes": [
{
"id": "RXhoaWJpdG9yXzU5NTIx",
"name": "Tech Solutions Booth",
"events": {
"nodes": [
{
"id": "RXZlbnRfMjg1NzM=",
"title": "Tech Conference 2025"
}
]
}
}
]
}
}
}
If pageInfo.hasNextPage is true, the user has more booths: run the query again with endCursor passed as cursor.after.
Step 3: Scan badges
Send scanned codes with the scanBadges mutation, along with the eventId and exhibitorId from step 2. Each badge has a code, and an optional rating and note.
The mutation accepts one or several badges per call. Send one badge for each scan, or queue scans while the device is offline and send them together in one batch.
- cURL
- Node.js
- PHP
- Python
curl -X POST \
https://developer.swapcard.com/exhibitor/graphql \
-H 'Authorization: YOUR_API_KEY_HERE' \
-H 'Content-Type: application/json' \
-d '{
"query": "mutation scanBadges($input: ScanBadgesInput!) { scanBadges(input: $input) { badges { errorCode connection { id rating note target { __typename ... on EventPerson { firstName lastName jobTitle email organization } } } } } }",
"variables": {
"input": {
"eventId": "RXZlbnRfMjg1NzM=",
"exhibitorId": "RXhoaWJpdG9yXzU5NTIx",
"scanBadges": [
{
"code": "BADGE_QR_CODE_123",
"rating": 5,
"note": "Very interested in our product"
}
]
}
}
}'
const scanBadgesMutation = `
mutation scanBadges($input: ScanBadgesInput!) {
scanBadges(input: $input) {
badges {
errorCode
connection {
id
rating
note
target {
__typename
... on EventPerson {
firstName
lastName
jobTitle
email
organization
}
}
}
}
}
}
`;
async function scanBadges(apiKey, eventId, exhibitorId, badges) {
const response = await fetch('https://developer.swapcard.com/exhibitor/graphql', {
method: 'POST',
headers: {
'Authorization': apiKey,
'Content-Type': 'application/json'
},
body: JSON.stringify({
query: scanBadgesMutation,
variables: {
input: {
eventId: eventId,
exhibitorId: exhibitorId,
scanBadges: badges
}
}
})
});
return await response.json();
}
// Example usage for single badge scan
const singleBadgeResult = await scanBadges(
'YOUR_API_KEY',
'RXZlbnRfMjg1NzM=',
'RXhoaWJpdG9yXzU5NTIx',
[
{
code: 'BADGE_QR_CODE_123',
rating: 5,
note: 'Very interested in our product'
}
]
);
// Example usage for batch scan (offline mode)
const batchScanResult = await scanBadges(
'YOUR_API_KEY',
'RXZlbnRfMjg1NzM=',
'RXhoaWJpdG9yXzU5NTIx',
[
{ code: 'BADGE_001', rating: 4, note: 'Interested in demo' },
{ code: 'BADGE_002', rating: 5, note: 'Hot lead - follow up ASAP' },
{ code: 'BADGE_003', rating: 3, note: 'General interest' }
]
);
<?php
$scanBadgesQuery = '
mutation scanBadges($input: ScanBadgesInput!) {
scanBadges(input: $input) {
badges {
errorCode
connection {
id
rating
note
target {
__typename
... on EventPerson {
firstName
lastName
jobTitle
email
organization
}
}
}
}
}
}
';
function scanBadges($apiKey, $eventId, $exhibitorId, $badges) {
global $scanBadgesQuery;
$data = json_encode([
'query' => $scanBadgesQuery,
'variables' => [
'input' => [
'eventId' => $eventId,
'exhibitorId' => $exhibitorId,
'scanBadges' => $badges
]
]
]);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://developer.swapcard.com/exhibitor/graphql');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: ' . $apiKey,
'Content-Type: application/json'
]);
$result = curl_exec($ch);
curl_close($ch);
return json_decode($result, true);
}
// Example usage
$badges = [
[
'code' => 'BADGE_QR_CODE_123',
'rating' => 5,
'note' => 'Very interested in our product'
]
];
$result = scanBadges('YOUR_API_KEY', 'RXZlbnRfMjg1NzM=', 'RXhoaWJpdG9yXzU5NTIx', $badges);
?>
import requests
import json
def scan_badges(api_key, event_id, exhibitor_id, badges):
query = """
mutation scanBadges($input: ScanBadgesInput!) {
scanBadges(input: $input) {
badges {
errorCode
connection {
id
rating
note
target {
__typename
... on EventPerson {
firstName
lastName
jobTitle
email
organization
}
}
}
}
}
}
"""
headers = {
'Authorization': api_key,
'Content-Type': 'application/json'
}
payload = {
'query': query,
'variables': {
'input': {
'eventId': event_id,
'exhibitorId': exhibitor_id,
'scanBadges': badges
}
}
}
response = requests.post(
'https://developer.swapcard.com/exhibitor/graphql',
headers=headers,
json=payload
)
return response.json()
# Example usage for single badge scan
single_badge = [{
'code': 'BADGE_QR_CODE_123',
'rating': 5,
'note': 'Very interested in our product'
}]
result = scan_badges('YOUR_API_KEY', 'RXZlbnRfMjg1NzM=', 'RXhoaWJpdG9yXzU5NTIx', single_badge)
# Example usage for batch scan (offline mode)
batch_badges = [
{'code': 'BADGE_001', 'rating': 4, 'note': 'Interested in demo'},
{'code': 'BADGE_002', 'rating': 5, 'note': 'Hot lead - follow up ASAP'},
{'code': 'BADGE_003', 'rating': 3, 'note': 'General interest'}
]
batch_result = scan_badges('YOUR_API_KEY', 'RXZlbnRfMjg1NzM=', 'RXhoaWJpdG9yXzU5NTIx', batch_badges)
{
"data": {
"scanBadges": {
"badges": [
{
"errorCode": null,
"connection": {
"id": "Q29ubmVjdGlvbl8xMTYzNDE=",
"rating": 5,
"note": "Very interested in our product",
"target": {
"__typename": "EventPerson",
"firstName": "John",
"lastName": "Doe",
"jobTitle": "CTO",
"email": "john.doe@example.com",
"organization": "Tech Corp"
}
}
}
]
}
}
}
Build a lead export
Build a tool that syncs lead data with a CRM or exports it for analysis.
Step 1: Store the API key
Collect and store the API key the same way as in step 1 of the badge-scanning app.
Step 2: Let the user pick a booth
Use the same myExhibitors query as in step 2 of the badge-scanning app to let users select the booths to export leads from.
Step 3: Fetch the leads
Use the leads query to retrieve all the leads of a booth for an event. The examples also show how to map each lead to a flat record for your CRM, and how to write the records to a CSV file.
- cURL
- Node.js
- PHP
- Python
curl -X POST \
https://developer.swapcard.com/exhibitor/graphql \
-H 'Authorization: YOUR_API_KEY_HERE' \
-H 'Content-Type: application/json' \
-d '{
"query": "query myLeads($eventId: ID!, $exhibitorId: ID!) { leads(eventId: $eventId, exhibitorId: $exhibitorId) { contacts { pageInfo { endCursor hasNextPage } nodes { id connectedAtEvent { id title } connectedAt isScanned rating note owner { id email firstName lastName jobTitle organization } target { ... on Contact { id email firstName lastName jobTitle organization } ... on EventPerson { id email firstName lastName jobTitle organization } } customFields { __typename ... on SelectField { id value definition { name id } } ... on TextField { id value definition { name } } } } } } }",
"variables": {
"eventId": "RXZlbnRfMjg1NzM=",
"exhibitorId": "RXhoaWJpdG9yXzU5NTIx"
}
}'
const myLeadsQuery = `
query myLeads($eventId: ID!, $exhibitorId: ID!) {
leads(eventId: $eventId, exhibitorId: $exhibitorId) {
contacts {
pageInfo {
endCursor
hasNextPage
}
nodes {
id
connectedAtEvent {
id
title
}
connectedAt
isScanned
rating
note
owner {
id
email
firstName
lastName
jobTitle
organization
}
target {
... on Contact {
id
email
firstName
lastName
jobTitle
organization
}
... on EventPerson {
id
email
firstName
lastName
jobTitle
organization
}
}
customFields {
__typename
... on SelectField {
id
value
definition {
name
id
}
}
... on TextField {
id
value
definition {
name
}
}
}
}
}
}
}
`;
async function exportLeads(apiKey, eventId, exhibitorId) {
const response = await fetch('https://developer.swapcard.com/exhibitor/graphql', {
method: 'POST',
headers: {
'Authorization': apiKey,
'Content-Type': 'application/json'
},
body: JSON.stringify({
query: myLeadsQuery,
variables: {
eventId: eventId,
exhibitorId: exhibitorId
}
})
});
const result = await response.json();
return result;
}
// Example usage
const leads = await exportLeads('YOUR_API_KEY', 'RXZlbnRfMjg1NzM=', 'RXhoaWJpdG9yXzU5NTIx');
// Process and format leads for your CRM
function formatLeadsForCRM(leads) {
return leads.data.leads.contacts.nodes.map(lead => ({
id: lead.id,
firstName: lead.target.firstName,
lastName: lead.target.lastName,
email: lead.target.email,
company: lead.target.organization,
jobTitle: lead.target.jobTitle,
rating: lead.rating,
notes: lead.note,
scannedAt: lead.connectedAt,
event: lead.connectedAtEvent.title,
customFields: lead.customFields.reduce((acc, field) => {
acc[field.definition.name] = field.value;
return acc;
}, {})
}));
}
const formattedLeads = formatLeadsForCRM(leads);
<?php
$myLeadsQuery = '
query myLeads($eventId: ID!, $exhibitorId: ID!) {
leads(eventId: $eventId, exhibitorId: $exhibitorId) {
contacts {
pageInfo {
endCursor
hasNextPage
}
nodes {
id
connectedAtEvent {
id
title
}
connectedAt
isScanned
rating
note
owner {
id
email
firstName
lastName
jobTitle
organization
}
target {
... on Contact {
id
email
firstName
lastName
jobTitle
organization
}
... on EventPerson {
id
email
firstName
lastName
jobTitle
organization
}
}
customFields {
__typename
... on SelectField {
id
value
definition {
name
id
}
}
... on TextField {
id
value
definition {
name
}
}
}
}
}
}
}
';
function exportLeads($apiKey, $eventId, $exhibitorId) {
global $myLeadsQuery;
$data = json_encode([
'query' => $myLeadsQuery,
'variables' => [
'eventId' => $eventId,
'exhibitorId' => $exhibitorId
]
]);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://developer.swapcard.com/exhibitor/graphql');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: ' . $apiKey,
'Content-Type: application/json'
]);
$result = curl_exec($ch);
curl_close($ch);
return json_decode($result, true);
}
function formatLeadsForCRM($leads) {
$formattedLeads = [];
foreach ($leads['data']['leads']['contacts']['nodes'] as $lead) {
$customFields = [];
foreach ($lead['customFields'] as $field) {
$customFields[$field['definition']['name']] = $field['value'];
}
$formattedLeads[] = [
'id' => $lead['id'],
'firstName' => $lead['target']['firstName'],
'lastName' => $lead['target']['lastName'],
'email' => $lead['target']['email'],
'company' => $lead['target']['organization'],
'jobTitle' => $lead['target']['jobTitle'],
'rating' => $lead['rating'],
'notes' => $lead['note'],
'scannedAt' => $lead['connectedAt'],
'event' => $lead['connectedAtEvent']['title'],
'customFields' => $customFields
];
}
return $formattedLeads;
}
// Example usage
$leads = exportLeads('YOUR_API_KEY', 'RXZlbnRfMjg1NzM=', 'RXhoaWJpdG9yXzU5NTIx');
$formattedLeads = formatLeadsForCRM($leads);
// Export to CSV
function exportToCSV($leads, $filename) {
$file = fopen($filename, 'w');
if (!empty($leads)) {
fputcsv($file, array_keys($leads[0]));
foreach ($leads as $lead) {
fputcsv($file, $lead);
}
}
fclose($file);
}
exportToCSV($formattedLeads, 'leads_export.csv');
?>
import requests
import json
import csv
from datetime import datetime
def export_leads(api_key, event_id, exhibitor_id):
query = """
query myLeads($eventId: ID!, $exhibitorId: ID!) {
leads(eventId: $eventId, exhibitorId: $exhibitorId) {
contacts {
pageInfo {
endCursor
hasNextPage
}
nodes {
id
connectedAtEvent {
id
title
}
connectedAt
isScanned
rating
note
owner {
id
email
firstName
lastName
jobTitle
organization
}
target {
... on Contact {
id
email
firstName
lastName
jobTitle
organization
}
... on EventPerson {
id
email
firstName
lastName
jobTitle
organization
}
}
customFields {
__typename
... on SelectField {
id
value
definition {
name
id
}
}
... on TextField {
id
value
definition {
name
}
}
}
}
}
}
}
"""
headers = {
'Authorization': api_key,
'Content-Type': 'application/json'
}
payload = {
'query': query,
'variables': {
'eventId': event_id,
'exhibitorId': exhibitor_id
}
}
response = requests.post(
'https://developer.swapcard.com/exhibitor/graphql',
headers=headers,
json=payload
)
return response.json()
def format_leads_for_crm(leads):
formatted_leads = []
for lead in leads['data']['leads']['contacts']['nodes']:
custom_fields = {}
for field in lead['customFields']:
custom_fields[field['definition']['name']] = field['value']
formatted_leads.append({
'id': lead['id'],
'firstName': lead['target']['firstName'],
'lastName': lead['target']['lastName'],
'email': lead['target']['email'],
'company': lead['target']['organization'],
'jobTitle': lead['target']['jobTitle'],
'rating': lead['rating'],
'notes': lead['note'],
'scannedAt': lead['connectedAt'],
'event': lead['connectedAtEvent']['title'],
'customFields': custom_fields
})
return formatted_leads
def export_to_csv(leads, filename):
if not leads:
return
with open(filename, 'w', newline='', encoding='utf-8') as csvfile:
writer = csv.DictWriter(csvfile, fieldnames=leads[0].keys())
writer.writeheader()
writer.writerows(leads)
# Example usage
leads = export_leads('YOUR_API_KEY', 'RXZlbnRfMjg1NzM=', 'RXhoaWJpdG9yXzU5NTIx')
formatted_leads = format_leads_for_crm(leads)
# Export to CSV
timestamp = datetime.now().strftime('%Y%m%d_%H%M%S')
filename = f'leads_export_{timestamp}.csv'
export_to_csv(formatted_leads, filename)
print(f"Exported {len(formatted_leads)} leads to {filename}")
# Example: Send to CRM webhook
def send_to_crm(leads, webhook_url):
for lead in leads:
response = requests.post(webhook_url, json=lead)
print(f"Sent lead {lead['id']} to CRM: {response.status_code}")
# send_to_crm(formatted_leads, 'https://your-crm-webhook.com/leads')
{
"data": {
"leads": {
"contacts": {
"pageInfo": {
"endCursor": "WyIyMDI1LTA5LTAzVDEzOjI4OjMzLjAwMFoiLDExNjM0MV0=",
"hasNextPage": false
},
"nodes": [
{
"id": "Q29ubmVjdGlvbl8xMTYzNDE=",
"connectedAtEvent": {
"id": "RXZlbnRfMjg1NzM=",
"title": "Tech Conference 2025"
},
"connectedAt": "2025-09-03 15:28:33",
"isScanned": true,
"rating": 5,
"note": "Very interested in our cloud solution",
"owner": {
"id": "VXNlcl8yNDExNg==",
"email": "exhibitor@techcorp.com",
"firstName": "Sarah",
"lastName": "Johnson",
"jobTitle": "Sales Manager",
"organization": "Tech Corp"
},
"target": {
"id": "VXNlcl8xNDc3MTg=",
"email": "john.doe@example.com",
"firstName": "John",
"lastName": "Doe",
"jobTitle": "CTO",
"organization": "Example Inc"
},
"customFields": [
{
"__typename": "SelectField",
"id": "RmllbGRWYWx1ZV8zMzg3ODA=",
"value": "yes",
"definition": {
"name": "Interested in Cloud Solution?",
"id": "RmllbGREZWZpbml0aW9uXzI0NzYyNg=="
}
}
]
}
]
}
}
}
}
The query returns one page of leads. When pageInfo.hasNextPage is true, pass endCursor as cursor.after on contacts to get the next page. See Export leads.
Next steps
- See every field you can request for a lead, including all custom field types, in Export leads.
- Handle scan errors such as
CODE_NOT_FOUND: see Scan badges. - Check the rate limits before you sync leads in bulk.
- Follow schema changes in the Changelog.