Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/abheekda1/awesomescibo-api


https://github.com/abheekda1/awesomescibo-api

List: awesomescibo-api

Last synced: 6 days ago
JSON representation

Awesome Lists containing this project

README

        

AwesomeSciBo API






An awesome API for hosting user submitted questions and rounds randomly generated by AwesomeSciBo!

## Bot
This API hosts rounds generated by the [AwesomeSciBo](https://github.com/ADawesomeguy/AwesomeSciBo) bot, which you can install [here](https://adat.link).

## Deployment/Installation
Deploying this API on your own server is relatively simple, and can be completed in just a few steps:

1. Clone and enter the repository
```bash
git clone https://github.com/ADawesomeguy/AwesomeSciBo-API/ && cd AwesomeSciBo-API
```

2. Install dependencies
```bash
npm i
```

3. Run process (default port is 8000)
```bash
DATABASE_NAME=[DB_NAME] API_PORT=[PORT] MASTER_API_KEY=[RANDOM STRING] npm run start
```

## Usage

### Schemas:
Question Schema:
```javascript
{
'Category': {
type: String,
enum: categoryNames
},
'Toss-Up Subcategory': {
type: String,
enum: subCategoryNames
},
'Bonus Subcategory': {
type: String,
enum: subCategoryNames
},
'Toss-Up Question Format': {
type: String,
enum: ["Multiple Choice", "Short Answer"]
},
'Toss-Up Question': String,
'Toss-Up Answer': String,
'Toss-Up Explanation': String,
'Bonus Question Format': {
type: String,
enum: ['Multiple Choice', 'Short Answer']
},
'Bonus Question': String,
'Bonus Answer': String,
'Bonus Explanation': String,
'Submitter': String,
'Timestamp': String,
'Source': String,
'Round': Number
}
```

### Endpoints:
`/questions`
Method `GET`: Returns a list of all questions in the database.
Parameters:
- `Limit` (default: 0)
- `Category`
- `Submitter`
- `Source`
- `q`

> Example: `curl https://api.adawesome.tech/questions?Limit=5&Category=Biology&Category=Chemistry&[email protected]&Source=LOST&q=Methane`

Returns: `Question Schema`.

`/questions/random`
Method `GET`: Returns a random question from the list.
Parameters:
- `Limit` (default: 1)
- `Category`
- `Submitter`
- `Source`
- `q`

> Example: `curl https://api.adawesome.tech/questions/ra ndom?Limit=5&Category=Biology&Category=Chemistry&[email protected]&Source=LOST&q=Methane`

Returns: `Question Schema`.

`/questions/[id]/update`
Method `POST`: Updates a question from the database with the given ID.

Data: `Question Schema`.

`/apikeys/request`
Method `POST`: Adds an email to the database with an API key that is disabled until validated by someone with the master API key (defined upon running to program).

Data:
```javascript
{
'Email': String
}
```

`/apikeys/validate`
Validates/invalidates API keys (best managed through webpage).

Method `POST` (if request contains `Master API Key` and `Email`): Will update a user's API key (normally validating/invalidating).

Data:
```javascript
{
'Master API Key': String,
'Email': String,
'Valid': Boolean
}
```

## Credit
The API was made by [@ADawesomeguy](https://github.com/ADawesomeguy) for his bot, [AwesomeSciBo](https://github.com/ADawesomeguy/AwesomeSciBo).