Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ONRAMP-5024): Update docs. Add apiKey to onramp utils #2077

Merged
merged 12 commits into from
Mar 31, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ The `fetchOnrampConfig` utility fetches the list of countries supported by Coinb
```tsx twoslash [code]
import { fetchOnrampConfig } from '@coinbase/onchainkit/fund';

// When using with OnchainKitProvider
const config = await fetchOnrampConfig();

// When using without OnchainKitProvider or in non-React environment
const config2 = await fetchOnrampConfig('your-api-key');
```

```json [return value]
Expand All @@ -35,6 +39,17 @@ const config = await fetchOnrampConfig();

:::

## Parameters

```typescript
/**
* Optional API key for Coinbase Onramp. If not provided, the API key from
* OnchainKitProvider will be used. Required when using the utility without
* OnchainKitProvider or in a non-React environment.
*/
apiKey?: string;
```

## Returns

`Promise<OnrampConfigResponseData>` - Returns a promise that resolves to the configuration data containing supported countries and their payment methods.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { fetchOnrampOptions } from '@coinbase/onchainkit/fund';
const options = await fetchOnrampOptions({
country: 'US',
subdivision: 'CA', // Required for US residents
apiKey: 'your-api-key', // Required when using without OnchainKitProvider or in non-React environment
});
```

Expand Down Expand Up @@ -60,6 +61,12 @@ const options = await fetchOnrampOptions({
* have state specific asset restrictions.
*/
subdivision?: string;
/**
* Optional API key for Coinbase Onramp. If not provided, the API key from
* OnchainKitProvider will be used. Required when using the utility without
* OnchainKitProvider or in a non-React environment.
*/
apiKey?: string;
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const quote = await fetchOnrampQuote({
paymentAmount: '100.00',
country: 'US',
subdivision: 'CA', // Required for US residents
apiKey: 'your-api-key', // Required when using without OnchainKitProvider or in non-React environment
});
```

Expand Down Expand Up @@ -93,6 +94,13 @@ const quote = await fetchOnrampQuote({
* because certain states (e.g., NY) have state specific asset restrictions.
*/
subdivision?: string;

/**
* Optional API key for Coinbase Onramp. If not provided, the API key from
* OnchainKitProvider will be used. Required when using the utility without
* OnchainKitProvider or in a non-React environment.
*/
apiKey?: string;
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const transactions = await fetchOnrampTransactionStatus({
partnerUserId: 'user123',
nextPageKey: '',
pageSize: '10',
apiKey: 'your-api-key', // Required when using without OnchainKitProvider or in non-React environment
});
```

Expand Down Expand Up @@ -48,6 +49,12 @@ const transactions = await fetchOnrampTransactionStatus({
partnerUserId: string; // Your unique identifier for the user
nextPageKey: string; // Token for pagination
pageSize: string; // Number of transactions per page
/**
* Optional API key for Coinbase Onramp. If not provided, the API key from
* OnchainKitProvider will be used. Required when using the utility without
* OnchainKitProvider or in a non-React environment.
*/
apiKey?: string;
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ type OnrampPurchaseCurrency = {
type OnrampPaymentCurrency = {
id: string;
limits: OnrampPaymentMethodLimit[];
iconUrl: string;
};

type OnrampNetwork = {
Expand Down