Build & ship ML APIs.
Endpoints turn your Python functions into API endpoints to form a serverless backend for your applications. You can build and test endpoints from the web IDE.
@routedecorator transforms any Python function into an endpoint. It's signature is as follows:
The decorator accepts two more named arguments:
is_public(boolean): is this a public endpoint? (Public endpoints do not require an API key to request.)
allowed_domains(list of strings): Sets a list of allowed domains to prevent CORS issues when invoking public endpoints.
You can invoke endpoints from the Blueprint web IDE or anywhere that can send an HTTP request: terminal, code, testing tools like Postman, and applications.
The url to invoke is formatted as follows:
Requests to private endpoints (by default, endpoints are private) must be accompanied with an API key for authentication. Pass the API key with an authorization header in the HTTP request. In cURL, that looks like:
- h "Authorization: API-KEY"
Your Python function should accept a single position argument,
request, which passes in a dictionary of input. Input includes HTTP method, headers (all request headers are passed to the function), and body.
Blueprint endpoints support GET, POST, PUT, and DELETE methods. For GET requests, you can pass data with query parameters. For others, use the HTTP request body.
Your Python function can output anything JSON-serializable. Blueprint will serialize it and wrap it in a dictionary with the following format:
You do not need to return
success: truefrom your function, Blueprint does that for you. The endpoint will return
success: falsein the error case.
Note that for now, functions always return a
200HTTP code, even in error cases. Proper HTTP codes will be added in the future.