# Getting Started

Let's get you accepting x402 payments in 5 minutes. No BS, no complexity.

## What You Need

* Ability to make HTTP requests (if you've ever called an API, you're good)
* A wallet address to receive payments (we'll help you get one if you don't have it)
* That's it. Seriously.

## What We're Doing

Super simple:

1. Get your API key (30 seconds)
2. Make one API call to verify payments
3. Done. You're accepting x402 payments.

## Setup

No SDK to install. No complex dependencies. Interface402 is just HTTP endpoints.

If you want to use our examples, grab the HTTP library for your language:

{% tabs %}
{% tab title="JavaScript/TypeScript" %}

```bash
npm install axios  # or use fetch
npm install ws     # for WebSocket support
```

{% endtab %}

{% tab title="Python" %}

```bash
pip install requests
pip install websocket-client
```

{% endtab %}

{% tab title="Rust" %}

```bash
cargo add reqwest
cargo add tokio-tungstenite  # for WebSocket support
```

{% endtab %}
{% endtabs %}

## Get Your API Key

1. Go to [interface402.dev](https://interface402.dev)
2. Sign up (literally just your email)
3. Grab your API key from the dashboard
4. Keep it secret (don't put it in your frontend code or GitHub)

## Accept Your First Payment

Copy, paste, done:

{% tabs %}
{% tab title="cURL" %}

```bash
curl -X POST https://api.interface402.dev/v1/payments/verify \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "payment_proof": "BASE64_ENCODED_PAYMENT_PROOF",
    "amount": 1000000,
    "recipient": "YOUR_WALLET_ADDRESS",
    "network": "solana"
  }'
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const response = await fetch('https://api.interface402.dev/v1/payments/verify', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_API_KEY'
  },
  body: JSON.stringify({
    payment_proof: 'BASE64_ENCODED_PAYMENT_PROOF',
    amount: 1000000,
    recipient: 'YOUR_WALLET_ADDRESS',
    network: 'solana'
  })
});

const data = await response.json();
console.log('Payment verified:', data);
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

response = requests.post(
    'https://api.interface402.dev/v1/payments/verify',
    headers={
        'Content-Type': 'application/json',
        'Authorization': 'Bearer YOUR_API_KEY'
    },
    json={
        'payment_proof': 'BASE64_ENCODED_PAYMENT_PROOF',
        'amount': 1000000,
        'recipient': 'YOUR_WALLET_ADDRESS',
        'network': 'solana'
    }
)

data = response.json()
print('Payment verified:', data)
```

{% endtab %}
{% endtabs %}

## That's It

You just verified an x402 payment. Told you it was simple.

## Real Example (Drop This Into Your App)

Here's how to actually use this in a real server:

```javascript
// Your API server receives a 402 Payment Required request
app.get('/api/protected-resource', async (req, res) => {
  const paymentProof = req.headers['x-payment-proof'];

  if (!paymentProof) {
    // No payment provided, return 402
    return res.status(402).json({
      error: 'Payment Required',
      amount: 1000000,
      recipient: 'YOUR_WALLET_ADDRESS',
      network: 'solana'
    });
  }

  try {
    // Verify the payment with Interface402
    const verification = await fetch('https://api.interface402.dev/v1/payments/verify', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'Authorization': 'Bearer YOUR_API_KEY'
      },
      body: JSON.stringify({
        payment_proof: paymentProof,
        amount: 1000000,
        recipient: 'YOUR_WALLET_ADDRESS',
        network: 'solana'
      })
    });

    const result = await verification.json();

    if (result.verified) {
      // Settle the payment
      await fetch('https://api.interface402.dev/v1/payments/settle', {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
          'Authorization': 'Bearer YOUR_API_KEY'
        },
        body: JSON.stringify({
          payment_id: result.payment_id
        })
      });

      // Payment verified and settled, return the resource
      return res.json({ data: 'Your protected resource' });
    } else {
      return res.status(402).json({ error: 'Invalid payment' });
    }
  } catch (error) {
    return res.status(500).json({ error: 'Payment verification failed' });
  }
});
```

## What's Next?

* Check out the [API Reference](https://docs.interface402.dev/api-reference/api-reference) for all the details
* See [more code examples](https://docs.interface402.dev/examples/examples) in your favorite language
* Set up [WebSocket streaming](https://docs.interface402.dev/api-reference/websocket-api) to get notified when payments happen
* Read about [x402](https://x402.gitbook.io/x402) if you're curious how it works under the hood

## Quick Tips

1. **Keep your API key secret** - Don't put it in frontend code or commit it to GitHub
2. **Check payment amounts** - Make sure you're getting paid what you expect
3. **Handle errors** - Networks fail, APIs timeout. Handle it gracefully.
4. **Start small** - Test with small amounts first
5. **Use WebSockets** - Get real-time updates when payments come through

## How x402 Works (The Simple Version)

1. Someone requests your API → You say "402, pay me $X"
2. They send a payment → You check it with Interface402
3. It's valid → You give them what they asked for

That's it. We handle all the blockchain stuff so you don't have to think about it.
