Back to all questions

Can I call the API from a browser (CORS)?

API Usage
api
cors
browser

Yes, the MatCraft API supports CORS (Cross-Origin Resource Sharing) from any origin. You can make API calls directly from client-side JavaScript without a proxy server.

javascript
// Works from any website
const resp = await fetch("https://api.matcraft.ai/api/v1/materials/mp-149");
const data = await resp.json();

CORS headers returned:

Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Allow-Headers: Authorization, Content-Type

Note that browser-based requests are still subject to rate limits based on the client IP address.

Related Questions