Skip to content

Commit

Permalink
Added new dist files
Browse files Browse the repository at this point in the history
  • Loading branch information
Nekidev committed Jan 7, 2023
2 parents efb0e5d 7e61f35 commit 5984c6a
Show file tree
Hide file tree
Showing 3 changed files with 271 additions and 3 deletions.
128 changes: 128 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 1,128 @@
# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
neki at nekidev.com.
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series
of actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
the community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.

Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 2,7 @@

![Loli count](https://count.getloli.com/get/@anime-api?theme=gelbooru)

The Anime API is a collection of wrappers for different types of free anime-related APIs.
The Anime API is a collection of wrappers for different types of free anime-related APIs. [Join our Discord server](https://discord.gg/PgQnuM3YnM).


## Why anime-api (and not others)?
Expand Down Expand Up @@ -52,7 52,7 @@ These are the currently supported and planned to add support for APIs:
| Anisearch | [Documentation](https://anisearch.com/developers) ||
| Anime News Network | [Documentation](https://www.animenewsnetwork.com/encyclopedia/api.php) ||
| Notify.moe (Anime Notifier) | [Documentation](https://notify.moe/api) ||
| Hmtai | [Documentation](https://hmtai.herokuapp.com/endpoints) | |
| Hmtai | [Documentation](https://hmtai.herokuapp.com/endpoints) |(down) |
| Nekos.life | [Documentation](https://github.com/Nekos-life/nekos.py) ||
| NekoBot | [Documentation](https://docs.nekobot.xyz/) ||
| Neko-Love | [Documentation](https://docs.neko-love.xyz/) ||
Expand All @@ -67,7 67,11 @@ These are the currently supported and planned to add support for APIs:
| Catboys | [Documentation](https://catboys.com/api) ||
| Anime Character Database | [Documentation](http://wiki.animecharactersdatabase.com/index.php?title=API_Access) ||
| AniBase | Not released ||
<<<<<<< HEAD
| Nekos API | [Documentation](https://nekos.nekidev.com/docs/rest-api/endpoints) ||
=======
| Nekos API | [Documentation](https://nekos.nekidev.com/docs) ||
>>>>>>> 7e61f35252454f28ba9e7fe52d1ab7defed957ad

### APIs by feature
Expand Down
138 changes: 137 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 43,143 @@ The list contains a `tuple` with 4 items for each API. For each `api` in the lis

## Nekos API

Nekos API is an actively developed free open-source anime images API that serves anime images. The project is mantained by [Nekidev](https://github.com/Nekidev) and the source code can be found in it's [GitHub repository](https://github.com/Nekidev/nekos-api). You can join the [official Discord server]()
Nekos API is an actively developed free open-source anime images API that serves anime images. The project is mantained by [Nekidev](https://github.com/Nekidev) and the source code can be found in it's [GitHub repository](https://github.com/Nekidev/nekos-api). You can [join the Discord server](https://discord.gg/PgQnuM3YnM) for more info, support and more.

The Nekos API wrapper is in the `anime_api.apis` module.

```python3
from anime_api.apis import NekosAPI

# If you own an access token, you can use it with the `token` argument.
api = NekosAPI()
```

The wrapper handles ratelimiting by itself. The API's rate limit is currently 1 request per second. If you call two or more methods without waiting a second, the wrappper will sleep until a new request can be made. For example:

```python3
import time

from anime_api.apis import NekosAPI


api = NekosAPI()

# First call, runs normally
api.get_random_image()

# Has not waited and will be ratelimmited. To prevent this, the wrapper will
# wait 1 second to make a new request.
api.get_image_by_id(image_id="some-uuid-v4")

# This simulates some processing your program makes that takes half a second.
time.sleep(.5)

# A new request is made but, as the previous request was made less than a
# second ago, the wrapper will wait the missing 500 milliseconds to make the
# request.
api.get_category_by_id(category_id="some-uuid-v4")
```

### `get_random_image(categories: Optional[list] = None)`

The `get_random_image` method returns an `anime_api.apis.nekos_api.objects.Image` object.

```python3
from anime_api.apis import NekosAPI

api = NekosAPI()

image = api.get_random_image(categories=["kemonomimi"])
```

### The `Image` class

The `Image` class contains all the information about an image returned from the API. It has the following properties:

- `id`: (`str`) The image's ID.
- `url`: (`str`) The image's URL.
- `artist`: (`Optional[Artist]`) The image's artist.
- `source`: (`Optional[_Source]`) The image's source (original post).
- `name`: (`str`) The name of the website where it was first posted.
- `url`: (`str`) The link to the original post.
- `original`: (`Optional[bool]`) Wether the image is drawn by the original author or is a fan art.
- `nsfw`: (`NsfwLevel`) The image's nsfw level. This property is an `Enum` and can be one of the following:
- `NsfwLevel.UNKNOWN`: The nsfw level is unknown (not yet added by the API admins). This level should be considered as NSFW since it may contain this type of content.
- `NsfwLevel.SFW`: Completely SFW and for all ages.
- `NsfwLevel.QUESTIONABLE`: Ecchi content. Not explicit, but suggestive.
- `NsfwLevel.NSFW`: Not Safe For Work. Not explicit, but borderline.
- `categories`: (`List[Category]`) A list of the image categories.
- `characters`: (`List[Character]`) A list of all characters that appear in the image.
- `created_at`: (`datetime.datetime`) The date and time when the image was added to the API.
- `etag`: (`str`) Useful for caching when requesting the image file.
- `size`: (`int`) The image file size in bytes.
- `mimetype`: (`str`) The image file's format.
- `color`: (`str`) The dominant color in the image in HEX. (i.e. #a0f4c3)
- `expires`: (`datetime.datetime`) The date and time when the image url expires. Image urls are signed so the expire an hour after requested.
- `dimens`: (`_Dimens`) The image dimensions. It has the following properties:
- `height`: (`int`) The image's height.
- `width`: (`int`) The image's width.
- `aspect_ratio`: (`str`) The image's aspect ratio. (i.e. 2:3, 1:2, 16:9)
- `orientation`: (`ImageOrientation`) This property is an Enum which has 3 possible values:
- `ImageOrientation.LANDSCAPE`: The image's width is bigger than it's height.
- `ImageOrientation.PORTRAIT`: The image's height is bigger than it's width.
- `ImageOrientation.SQUARE`: The image's height is the same as it's width.

### `get_random_images(categories: Optional[list] = None, limit: int = 10)`

The `get_random_images` method works exactly the same as the `get_random_image` method, but instead or returning a single image, it returns a list of them. You can specify how many images will be returned with the `limit` argument (max 25).

```python3
from anime_api.apis import NekosAPI

api = NekosAPI()

images = api.get_random_images(categories=["catgirl"])

for image in images:
print(image.url)
```

### `get_image_by_id(image_id: str)`

The `get_image_by_id` method returns an `Image` object with the specified ID.

```python3
from anime_api.apis import NekosAPI

api = NekosAPI()

image = api.get_image_by_id(image_id="some-uuid-v4")

print(image.url)
```

IDs identify each image. Take into account that the API ToS do not allow data storage for more than an hour. This means that you cannot store image IDs or any other type of data in your database or any other kind of data storage.

### `get_artist_by_id(artist_id: str)`

The `get_artist_by_id` method returns the information for the specified artist.

```python3
from anime_api.apis import NekosAPI

api = NekosAPI()

artist = api.get_artist_by_id(artist_id="some-uuid-v4)

print(artist.name)
```

This method returns an `anime_api.apis.nekos_api.objects.Artist` object.

### The `Artist` class.

The `Artist` class represents an illustrator which has images in the API. It has the following properties:

- `id`: (`str`) The artist's ID.
- `name`: (`str`) The artist's name.
- `url`: (`Optional[str]`) A link to the artist's official website/social media account.
- `images`: (`Optional[int]`) The amount of images uploaded to the API. This property is only present when fetching the artist by ID.

## Anime Facts Rest API

Expand Down

0 comments on commit 5984c6a

Please sign in to comment.