Skip to main content
GET
/
api
/
v1
/
impressions
/
{id}
curl -X GET "http://localhost:3000/api/v1/impressions/imp_123abc" \
  -H "Authorization: Bearer sk_your_secret_key_here"
{
  "id": "imp_123abc",
  "poster_id": "poster_123abc",
  "program_id": "prog_123abc",
  "student_id": "user_123abc",
  "scanned_at": "2024-01-15T10:30:00Z",
  "user_agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15",
  "ip_address": "192.168.1.1",
  "metadata": {
    "device_type": "mobile",
    "location": "campus_center",
    "referrer": "direct"
  }
}
Retrieve detailed information about a specific QR code scan (impression) by its unique ID. Use this endpoint to fetch complete scan details including timestamp, device information, and associated poster.

Overview

The Get Impression endpoint returns comprehensive information about a single QR code scan. This is useful for:
  • Viewing detailed scan information
  • Linking impressions to referrals
  • Debugging scan issues
  • Building impression detail pages
  • Tracking individual user journeys

Authentication

This endpoint requires authentication using a Bearer token in the Authorization header:
Authorization: Bearer sk_your_secret_key_here

Path Parameters

id
string
required
The unique identifier of the impression you want to retrieve. This ID is returned when a QR code is scanned and is used when creating referrals.Example: imp_123abc

Request Example

curl -X GET "http://localhost:3000/api/v1/impressions/imp_123abc" \
  -H "Authorization: Bearer sk_your_secret_key_here"

Response

The API returns a detailed impression object:
id
string
required
Unique identifier for the impression. Use this ID when creating a referral.
poster_id
string
required
ID of the poster whose QR code was scanned.
program_id
string
required
ID of the program this impression belongs to.
student_id
string
required
ID of the student ambassador who placed the poster.
scanned_at
string
required
ISO 8601 timestamp of when the QR code was scanned.
user_agent
string
User agent string of the device that scanned the QR code. Useful for identifying device type and browser.
ip_address
string
IP address of the device that scanned the QR code (if available).
metadata
object
Additional metadata about the scan, such as device type, location, or custom fields.

Response Example

{
  "id": "imp_123abc",
  "poster_id": "poster_123abc",
  "program_id": "prog_123abc",
  "student_id": "user_123abc",
  "scanned_at": "2024-01-15T10:30:00Z",
  "user_agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15",
  "ip_address": "192.168.1.1",
  "metadata": {
    "device_type": "mobile",
    "location": "campus_center",
    "referrer": "direct"
  }
}

Error Responses

401
object
Unauthorized - Invalid or missing API key
{
  "error": "Unauthorized",
  "message": "Invalid or missing API key"
}
404
object
Not Found - The impression with the specified ID does not exist
{
  "error": "Not Found",
  "message": "Impression not found"
}

Use Cases

Creating a Referral from an Impression

When a user signs up after scanning a QR code, use the impression ID to create a referral:
async function createReferralFromImpression(impressionId, signupData) {
  // First, verify the impression exists
  const impression = await getImpressionDetails(impressionId);
  
  // Then create the referral using the impression ID
  const referral = await fetch('http://localhost:3000/api/v1/referrals', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${API_KEY}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      impression_id: impressionId,
      first_name: signupData.firstName,
      last_name: signupData.lastName,
      email: signupData.email
    })
  });
  
  return await referral.json();
}

Viewing Impression Details

Fetch impression information to display in a detail view:
async function getImpressionDetails(impressionId) {
  try {
    const response = await fetch(
      `http://localhost:3000/api/v1/impressions/${impressionId}`,
      {
        headers: {
          'Authorization': `Bearer ${API_KEY}`
        }
      }
    );
    
    if (response.status === 404) {
      throw new Error('Impression not found');
    }
    
    if (!response.ok) {
      throw new Error('Failed to fetch impression');
    }
    
    return await response.json();
  } catch (error) {
    console.error('Error fetching impression:', error);
    throw error;
  }
}

Building Impression Detail Component

Create a React component to display impression details:
async function ImpressionDetail({ impressionId }) {
  const [impression, setImpression] = useState(null);
  const [loading, setLoading] = useState(true);
  
  useEffect(() => {
    async function fetchImpression() {
      try {
        const response = await fetch(
          `http://localhost:3000/api/v1/impressions/${impressionId}`,
          {
            headers: {
              'Authorization': `Bearer ${API_KEY}`
            }
          }
        );
        
        if (response.ok) {
          const data = await response.json();
          setImpression(data);
        }
      } catch (error) {
        console.error('Error:', error);
      } finally {
        setLoading(false);
      }
    }
    
    fetchImpression();
  }, [impressionId]);
  
  if (loading) return <div>Loading...</div>;
  if (!impression) return <div>Impression not found</div>;
  
  return (
    <div>
      <h1>QR Code Scan Details</h1>
      <p>Scanned at: {new Date(impression.scanned_at).toLocaleString()}</p>
      <p>Poster ID: {impression.poster_id}</p>
      <p>Device: {impression.user_agent || 'Unknown'}</p>
    </div>
  );
}

Best Practices

  1. Link impressions to referrals - Always use the impression ID when creating referrals
  2. Cache impression data - Impression information doesn’t change after creation
  3. Handle 404 errors - Always check if the impression exists
  4. Track device information - Use user_agent and metadata to analyze device types
  5. Monitor scan timing - Use scanned_at to analyze peak scan times

Rate Limits

This endpoint is subject to rate limiting. Check response headers for rate limit information.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

id
string
required

Impression ID

Response

Impression details

The response is of type object.