This commit is contained in:
d0c 2023-09-01 12:34:39 +02:00
parent 47cc588c0f
commit 7c7a417092

131
API.md Normal file
View file

@ -0,0 +1,131 @@
# SuitablePhones API Documentation
## Table of Contents
1. [Introduction](#introduction)
2. [Base URL](#base-url)
3. [API Endpoints](#api-endpoints)
- [Search Devices](#search-devices)
- [Get a Single Device](#get-a-single-device)
- [Get Devices with Filters](#get-devices-with-filters)
4. [Models](#models)
5. [Errors](#errors)
6. [Notes](#notes)
---
## Introduction
This API allows you to query devices and fetch details related to them. The API offers various endpoints to facilitate different types of search queries.
---
## Base URL
The base URL for all the API endpoints is `http://[your_domain]/api/`.
---
## API Endpoints
### Search Devices
- **Method:** `GET`
- **Endpoint:** `/devices/search`
- **Query Parameters:**
- `q`: String to search in `codename`, `name`, or `vendor`.
#### Example
```bash
GET /api/devices/search?q=iphone
```
#### Response
Returns a JSON array of all devices that match the query string in either `codename`, `name`, or `vendor`.
---
### Get a Single Device
- **Method:** `GET`
- **Endpoint:** `/devices/single`
- **Query Parameters:**
- `codename`: The codename of the device.
#### Example
```bash
GET /api/devices/single?codename=Pixel_4a
```
#### Response
Returns a JSON object of the device that matches the codename.
---
### Get Devices with Filters
- **Method:** `GET`
- **Endpoint:** `/devices`
- **Query Parameters:**
- `name`: String to search in `name`.
- `megapixel`: Minimal camera megapixels.
- `size_in`: Maximum screen size in inches.
- `release`: Release year.
- `resolution`: Screen resolution.
- `screen_type`: Screen technology type.
- `soc`: System on Chip.
- `storage`: Storage size.
- `vendor`: Vendor name.
- `version`: OS version.
- `short_view`: Use this parameter for a shorter view of devices.
#### Example
```bash
GET /api/devices?megapixel=3&vendor=Apple&short_view=true
```
#### Response
Returns a JSON array of all devices that match the query parameters.
---
## Models
### Device
- `codename` (string): Codename of the device.
- `name` (string): Name of the device.
- `megapixel` (float): Camera quality in megapixels.
- `size_in` (float): Screen size in inches.
- `release` (string): Release year.
- `resolution` (string): Screen resolution.
- `screen_type` (string): Screen technology.
- `soc` (string): System on Chip.
- `storage` (string): Storage size.
- `vendor` (string): Vendor name.
- `version` (string): OS version.
---
## Errors
- `400 Bad Request`: The request could not be understood or was missing required parameters.
- `404 Not Found`: Resource was not found.
- `500 Internal Server Error`: An error occurred on the server.
---
## Notes
- The `short_view` parameter will return a trimmed-down version of the device object.
- The `megapixel` and `size_in` parameters accept decimal values.
---
I hope this helps! Feel free to customize it further as you see fit.