<commit_before># IMangaScans API

## Convention

Unless specified otherwise, all responses will be served as JSON.  The common exception to this rule will be in cases where files are served rather than informational responses.

`GET` and `DELETE` requests will accept parameters in URL query string parameters.

`POST` and other types of requests will accept parameters as JSON in the body of the request.

JSON responses will always contain an `error` field.  If an error occurred in processing the request, it will contain a string describing the error. Otherwise, `error` will be `null`.

## Notation

Types will be represented with the name of a type, such as `string`, `bool`, `integer`, `float` etc.

Compound types will be represented as `[<type>]` for arrays with values of all the same type, `[<type1>, <type2>, ... <typeN>]` in the case of an array with exactly N values whose types are predefined, and `{"key1": <type>, "key2": <type>}` in the case of objects. Objects may also have the type `{...}`, indicating that they can contain any combination of keys and values.

Any parameter that is optional will have a type prefixed with `optional`. For example, the type `optional integer` indicates that the field is not required but, if provided, must be an integer.

## Endpoints

### Download an archive of a release

```
GET /{projectName}-{chapter}{groupName}{checksum}.{version}.zip
```

* Downloads the release archive
* The route is invalid if the release is not in released state
* The archive may not contain any folders
* The archive must contain a credit page.


#### Parameters

Instead of this endpoint accepting parameters in the usual URL query parameter format, the name of the zip file requested contains positional arguments in the URL.

Name | Type | Description
-----|------|------------
projectName | string | The name of a project
chapter | string | The id of the release
groupName | string | The shorthand name of the scanlation group, e.g. ims
checksum | string | The hex encoding of the sha256 hash of the zip file
version | integer | The version number of the release, starting from 1

#### Response

* Status 200: The zip file will be served directly
* Status 4xx: Invalid request, with a string error message
* Status 5xx: Server error, with a string error message

### Download a single image

```
GET /{projectName}-{chapter}.{version}/{page}.{ext}
```

* Downloads the requested image from the archive
* The route is valid even if the release is not in released state

#### Parameters

Instead of this endpoint accepting parameters in the usual URL query parameter format, the name of the image file requested contains positional arguments in the URL.

Name | Type | Description
-----|------|------------
projectName | string | The name of a project
chapter | string | The chapter number
version | integer | The version number of the release, starting from 1
page | string | The page number, starting from 1
ext | string | The filetype extension of the page's file

#### Response

* Status 200: The image file will be served directly
* Status 4xx: Invalid request, with a string error message
* Status 5xx: Server error, with a string error message

### Get a list of all projects

```
GET /projects
```

#### Parameters

Name | Type | Description
-----|------|------------
ordering | optional string | Either "newest" or "oldest" for newest first or oldest first respectively

#### Response

Name | Type | Description
-----|------|------------
projects | `[{"id": string, "name": string, "createdAt": string}]` | An array containing objects that identify all existing projects

### Create a new project

```
POST /projects
```

#### Parameters

Name | Type | Description
-----|------|------------
name | string | The human-readable name of the project
filename | string | The projectName identifier for archive filenames. Must be unique
description | string | A longer description of the project
status | string | The current status of the project. One of "ongoing", "complete", "dropped", etc.

#### Response

Name | Type | Description
-----|------|------------
success | bool | True if there was no problem creating the project
id | integer | The id of the newly created project, if successful

### Get information about a project

```
GET /projects/{projectId}
```

#### Parameters

Name | Type | Description
-----|------|------------
projectId | integer | The identifier of a project, as returned by the create endpoint

#### Response

Name | Type | Description
-----|------|------------
createdAt | string | The date when the project was created
name | string | The descriptive name of the project
filename | string | The projectName
status | string | The current status of the project
description | string | The description of the project

### Update project information

```
PUT /projects/{projectId}
```

#### Paramters

Name | Type | Description
-----|------|------------
projectId | integer | The unique identifier for the project
name | string | A new human-readable name for the project
filename | string | A new projectName for the project
status | string | The new status of the project
description | string | A new description for the project

#### Response

Name | Type | Description
-----|------|------------
success | bool | True if the update could take place, else false

### Delete a project
<commit_msg>Rename project.filename to projectName since it's just better to be consistent<commit_after># IMangaScans API

## Convention

Unless specified otherwise, all responses will be served as JSON.  The common exception to this rule will be in cases where files are served rather than informational responses.

`GET` and `DELETE` requests will accept parameters in URL query string parameters.

`POST` and other types of requests will accept parameters as JSON in the body of the request.

JSON responses will always contain an `error` field.  If an error occurred in processing the request, it will contain a string describing the error. Otherwise, `error` will be `null`.

## Notation

Types will be represented with the name of a type, such as `string`, `bool`, `integer`, `float` etc.

Compound types will be represented as `[<type>]` for arrays with values of all the same type, `[<type1>, <type2>, ... <typeN>]` in the case of an array with exactly N values whose types are predefined, and `{"key1": <type>, "key2": <type>}` in the case of objects. Objects may also have the type `{...}`, indicating that they can contain any combination of keys and values.

Any parameter that is optional will have a type prefixed with `optional`. For example, the type `optional integer` indicates that the field is not required but, if provided, must be an integer.

## Endpoints

### Download an archive of a release

```
GET /{projectName}-{chapter}{groupName}{checksum}.{version}.zip
```

* Downloads the release archive
* The route is invalid if the release is not in released state
* The archive may not contain any folders
* The archive must contain a credit page.


#### Parameters

Instead of this endpoint accepting parameters in the usual URL query parameter format, the name of the zip file requested contains positional arguments in the URL.

Name | Type | Description
-----|------|------------
projectName | string | The name of a project
chapter | string | The id of the release
groupName | string | The shorthand name of the scanlation group, e.g. ims
checksum | string | The hex encoding of the sha256 hash of the zip file
version | integer | The version number of the release, starting from 1

#### Response

* Status 200: The zip file will be served directly
* Status 4xx: Invalid request, with a string error message
* Status 5xx: Server error, with a string error message

### Download a single image

```
GET /{projectName}-{chapter}.{version}/{page}.{ext}
```

* Downloads the requested image from the archive
* The route is valid even if the release is not in released state

#### Parameters

Instead of this endpoint accepting parameters in the usual URL query parameter format, the name of the image file requested contains positional arguments in the URL.

Name | Type | Description
-----|------|------------
projectName | string | The name of a project
chapter | string | The chapter number
version | integer | The version number of the release, starting from 1
page | string | The page number, starting from 1
ext | string | The filetype extension of the page's file

#### Response

* Status 200: The image file will be served directly
* Status 4xx: Invalid request, with a string error message
* Status 5xx: Server error, with a string error message

### Get a list of all projects

```
GET /projects
```

#### Parameters

Name | Type | Description
-----|------|------------
ordering | optional string | Either "newest" or "oldest" for newest first or oldest first respectively

#### Response

Name | Type | Description
-----|------|------------
projects | `[{"id": string, "name": string, "createdAt": string}]` | An array containing objects that identify all existing projects

### Create a new project

```
POST /projects
```

#### Parameters

Name | Type | Description
-----|------|------------
name | string | The human-readable name of the project
projectName| string | The projectName identifier for archive filenames. Must be unique
description | string | A longer description of the project
status | string | The current status of the project. One of "ongoing", "complete", "dropped", etc.

#### Response

Name | Type | Description
-----|------|------------
success | bool | True if there was no problem creating the project
id | integer | The id of the newly created project, if successful

### Get information about a project

```
GET /projects/{projectId}
```

#### Parameters

Name | Type | Description
-----|------|------------
projectId | integer | The identifier of a project, as returned by the create endpoint

#### Response

Name | Type | Description
-----|------|------------
createdAt | string | The date when the project was created
name | string | The descriptive name of the project
projectName | string | The unique project name shorthand, used in file names
status | string | The current status of the project
description | string | The description of the project

### Update project information

```
PUT /projects/{projectId}
```

#### Paramters

Name | Type | Description
-----|------|------------
projectId | integer | The unique identifier for the project
name | string | A new human-readable name for the project
projectName | string | A new unique shorthand name, to use in filenames
status | string | The new status of the project
description | string | A new description for the project

#### Response

Name | Type | Description
-----|------|------------
success | bool | True if the update could take place, else false

### Delete a project

{'fraction_non_alphanumeric': 0.11972738994289925, 'fraction_numerical': 0.003683919690550746, 'mean_word_length': 3.5226988754685546, 'pattern_counts': {'":': 10, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5782513', 'n_tokens_mistral': 2708, 'n_tokens_neox': 2592, 'n_words': 1470}