NAV
python curl

Introduction

Welcome to the Lunar API! With our async API, you can retrieve image data for NSFW images of multiple categories. Image generation, such as welcome banners, memes, and more!

We have language bindings in Python! You can view code examples in the dark area to the right, and you can switch the programming language of the examples with the tabs in the top right (only currently supported languages are provided a tab).

All examples are in assumption that our wrapper is being used.

Content Warning: This API includes NSFW content underneath the Image API (NSFW) section.

Authentication

To authorize, use this code:

from lunarapi import Client, endpoints
from aiohttp import ClientSession
import asyncio

token = "<JWT>" # Replace with your Lunar API Key.

async def main():
  async with ClientSession() as session:
    client = Client(session=session, token=token)

asyncio.run(main())

Make sure to replace <JWT> with your API key.

Lunar API uses API keys to allow access to the API. You can apply for an API key at our application page or request for it directly in our Discord

Lunar expects for the API key to be included in all API requests to the server in a header that looks like the following:

Authorization: eyJ0eXAiORX00IsyJzW4Ovsux-ciOiJIUzI1NiJ9.eyJpYXQiOjE2NTg3MjE0NDUsIm5iZiI6MTY1ODcyMTQ0NSwianRpIjoiNDQ5MDkwZjQtNTg5NC00ODNiLTkzMDEtMWU3OTNlMzJmZmRkIiwiaWRlbnRpdHkiOiJMdW5hciIsImZyZXNoIjpmYWxzZSwidHlwZSI6ImFjY2VzcyJ9.nJsgmXX6jy1BZX8soYuQcDwUXM

Register

curl --request POST \
  --url https://api.lunardev.group/register \
  --header 'Content-Type: application/json' \
  --data '{
    "username": "username",
    "password": "password"
}'

The above returns a JSON object:

{
  "bearer": "eYxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}

HTTP Request

POST https://api.lunardev.group/register

Returned data

Key | Description bearer | LunarAPI Authentication token

Register for a JWT key using username and password in a JSON Body

Image Generation

Welcome

from lunarapi import Client, endpoints
from aiohttp import ClientSession
import asyncio

token = ""  # Replace with your Lunar API Key.

async def main():
    async with ClientSession() as session:
        client = Client(session=session, token=token)

        image = await client.request(endpoints.generate_welcome, avatar="https://dash.lunardev.group/u/logo.png", username="WinterFe#2000", members="300")
        await image.save("image.jpg")

asyncio.run(main())

### Discord.py Usage:
import lunarapi
import discord

@commands.command()
async def welcome(self, ctx, *, user: Member, member_count: str):
    async with aiohttp.ClientSession() as session:
        client = lunarapi.Client(
            session=session,
            token=token,
        )
        image = await client.request(
            lunarapi.endpoints.generate_welcome,
            avatar=user.avatar.url,
            username=user.name,
            members=member_count
        )

        await ctx.send(file=await image.file(discord))

The above returns a Bytes-like object:

[Image]

This endpoint generates a welcome image Discord.py users: In reference to the example on the Python tab, image.file(discord) is built into our wrapper.

HTTP Request

GET https://api.lunardev.group/gen/welcome?avatar=url&username=text&members=str

Query Parameters

Parameter Default Description Required
avatar null Set the profile image in the image. True
username null Set the username for the user in the image True
members null Set the member count for the image True

Result:

Achievement

from lunarapi import Client, endpoints
from aiohttp import ClientSession
import asyncio

token = ""  # Replace with your Lunar API Key.

async def main():
    async with ClientSession() as session:
        client = Client(session=session, token=token)

        image = await client.request(endpoints.generate_achievement, text="Woohoo! I made a request!")
        await image.save("image.jpg")

asyncio.run(main())

### Discord.py Usage:
import lunarapi
import discord

@commands.command()
    async def achievement(self, ctx, *, text: str):
        async with aiohttp.ClientSession() as session:
            client = lunarapi.Client(
                session=session,
                token=token,
            )
            image = await client.request(
                lunarapi.endpoints.generate_achievement, text=text
            )

            await ctx.send(file=await image.file(discord))

The above returns a Bytes-like object:

[Image]

This endpoint generates a Minecraft achievement :D

HTTP Request

GET https://api.lunardev.group/gen/achievement?text=text[&icon=int]

Query Parameters

Parameter Default Description Required
text null Set the text for the achievement. True
icon random Set the icon for the achievement. This is an int 1-45 False

Result:

Amiajoke

from lunarapi import Client, endpoints
from aiohttp import ClientSession
import asyncio

token = ""  # Replace with your Lunar API Key.

async def main():
    async with ClientSession() as session:
        client = Client(session=session, token=token)

        image = await client.request(endpoints.generate_amiajoke, image="https://dash.lunardev.group/u/logo.png")
        await image.save("image.jpg")

asyncio.run(main())

### Discord.py Usage:
import lunarapi
import discord

@commands.command()
async def amiajoke(self, ctx, *, user: discord.User):
    async with aiohttp.ClientSession() as session:
        client = lunarapi.Client(
            session=session,
            token=token,
        )
        image = await client.request(
            lunarapi.endpoints.generate_amiajoke, image=user.avatar.url
        )

        await ctx.send(file=await image.file(discord))

The above returns a Bytes-like object:

[Image]

This endpoint generates a meme

HTTP Request

GET https://api.lunardev.group/gen/amiajoke?image=url

Query Parameters

Parameter Default Description Required
image null Set the image top place on the meme. True

Result:

Bad

from lunarapi import Client, endpoints
from aiohttp import ClientSession
import asyncio

token = ""  # Replace with your Lunar API Key.

async def main():
    async with ClientSession() as session:
        client = Client(session=session, token=token)

        image = await client.request(endpoints.generate_bad, image="https://dash.lunardev.group/u/logo.png")
        await image.save("image.jpg")

asyncio.run(main())

### Discord.py Usage:
import lunarapi
import discord

@commands.command()
async def amiajoke(self, ctx, *, user: discord.User):
    async with aiohttp.ClientSession() as session:
        client = lunarapi.Client(
            session=session,
            token=token,
        )
        image = await client.request(
            lunarapi.endpoints.generate_bad, image=user.avatar.url
        )

        await ctx.send(file=await image.file(discord))

The above returns a Bytes-like object:

[Image]

This endpoint generates a meme

HTTP Request

GET https://api.lunardev.group/gen/bad?image=url

Query Parameters

Parameter Default Description Required
image null Set the image top place on the meme. True

Result:

Calling

from lunarapi import Client, endpoints
from aiohttp import ClientSession
import asyncio

token = ""  # Replace with your Lunar API Key.

async def main():
    async with ClientSession() as session:
        client = Client(session=session, token=token)

        image = await client.request(endpoints.generate_calling,text="Ring ring haha")
        await image.save("image.jpg")

asyncio.run(main())

### Discord.py Usage:
import lunarapi
import discord

@commands.command()
async def amiajoke(self, ctx, *, text: str):
    async with aiohttp.ClientSession() as session:
        client = lunarapi.Client(
            session=session,
            token=token,
        )
        image = await client.request(
            lunarapi.endpoints.generate_calling, text=text
        )

        await ctx.send(file=await image.file(discord))

The above returns a Bytes-like object:

[Image]

This endpoint generates a meme. Tbh we don't understand this meme, we just wanted more memes.

HTTP Request

GET https://api.lunardev.group/gen/calling?text=text

Query Parameters

Parameter Default Description Required
text null Set the text for the meme. True

Result:

Image API (SFW)

You can use /raw at the end of the image endpoint to recieve a raw bytes-like object!


Hug

from lunarapi import Client, endpoints
from aiohttp import ClientSession
import asyncio

token = ""  # Replace with your Lunar API Key.

async def main():
    async with ClientSession() as session:
        client = Client(session=session, token=token)

        image = await client.request(endpoints.sfw("hug"))
        print(await image.to_dict())

asyncio.run(main())

### Discord.py Usage:
import lunarapi

@commands.command()
async def hug(self, ctx):
    async with aiohttp.ClientSession() as session:
        client = lunarapi.Client(
            session=session,
            token=token,
        )
        image = await client.request(
            lunarapi.endpoints.sfw("hug")
        )
        data = await image.to_dict()

        await ctx.send(f"{data['url']}")

The above returns a JSON object:

{
    "id": "hug_MF2cWkDS7",
    "url": "https://api.lunardev.group/hug/hug_MF2cWkDS7.jpg"
}

This endpoint generates a JSON object

HTTP Request

GET https://api.lunardev.group/sfw/hug

Returned data

Key Description
id This is what we refer to as the image ID. It is useful for logging and reporting purposes.
url The direct image URL for the image retrieved. You can use this in embeds and whatever else you wish.

Pat

from lunarapi import Client, endpoints
from aiohttp import ClientSession
import asyncio

token = ""  # Replace with your Lunar API Key.

async def main():
    async with ClientSession() as session:
        client = Client(session=session, token=token)

        image = await client.request(endpoints.sfw("pat"))
        print(await image.to_dict())

asyncio.run(main())

### Discord.py Usage:
import lunarapi

@commands.command()
async def pat(self, ctx):
    async with aiohttp.ClientSession() as session:
        client = lunarapi.Client(
            session=session,
            token=token,
        )
        image = await client.request(
            lunarapi.endpoints.sfw("pat")
        )
        data = await image.to_dict()

        await ctx.send(f"{data['url']}")

The above returns a JSON object:

{
    "id": "hug_MF2cWkDS7",
    "url": "https://api.lunardev.group/pat/pat_MF2cWkDS7.jpg"
}

This endpoint generates a JSON object

HTTP Request

GET https://api.lunardev.group/sfw/pat

Returned data

Key Description
id This is what we refer to as the image ID. It is useful for logging and reporting purposes.
url The direct image URL for the image retrieved. You can use this in embeds and whatever else you wish.

Image API (NSFW)

You can use /raw at the end of the image endpoint to recieve a raw bytes-like object!


Ahegao

from lunarapi import Client, endpoints
from aiohttp import ClientSession
import asyncio

token = ""  # Replace with your Lunar API Key.

async def main():
    async with ClientSession() as session:
        client = Client(session=session, token=token)

        image = await client.request(endpoints.nsfw("ahegao"))
        print(await image.to_dict())

asyncio.run(main())

### Discord.py Usage:
import lunarapi

@commands.command()
async def ahegao(self, ctx):
    async with aiohttp.ClientSession() as session:
        client = lunarapi.Client(
            session=session,
            token=token,
        )
        image = await client.request(
            lunarapi.endpoints.nsfw("ahegao")
        )
        data = await image.to_dict()

        await ctx.send(f"{data['url']}")

The above returns a JSON object:

{
    "id": "ahegao_MF2cWkDS7",
    "url": "https://api.lunardev.group/ahegao/ahegao_MF2cWkDS7.jpg"
}

This endpoint generates a JSON object

HTTP Request

GET https://api.lunardev.group/nsfw/ahegao

Returned data

Key Description
id This is what we refer to as the image ID. It is useful for logging and reporting purposes.
url The direct image URL for the image retrieved. You can use this in embeds and whatever else you wish.

Ass

from lunarapi import Client, endpoints
from aiohttp import ClientSession
import asyncio

token = ""  # Replace with your Lunar API Key.

async def main():
    async with ClientSession() as session:
        client = Client(session=session, token=token)

        image = await client.request(endpoints.nsfw("ass"))
        print(await image.to_dict())

asyncio.run(main())

### Discord.py Usage:
import lunarapi

@commands.command()
async def ass(self, ctx):
    async with aiohttp.ClientSession() as session:
        client = lunarapi.Client(
            session=session,
            token=token,
        )
        image = await client.request(
            lunarapi.endpoints.nsfw("ass")
        )
        data = await image.to_dict()

        await ctx.send(f"{data['url']}")

The above returns a JSON object:

{
    "id": "ass_MF2cWkDS7",
    "url": "https://api.lunardev.group/ass/ass_MF2cWkDS7.jpg"
}

This endpoint generates a JSON object

HTTP Request

GET https://api.lunardev.group/nsfw/ass

Returned data

Key Description
id This is what we refer to as the image ID. It is useful for logging and reporting purposes.
url The direct image URL for the image retrieved. You can use this in embeds and whatever else you wish.

Boobs

from lunarapi import Client, endpoints
from aiohttp import ClientSession
import asyncio

token = ""  # Replace with your Lunar API Key.

async def main():
    async with ClientSession() as session:
        client = Client(session=session, token=token)

        image = await client.request(endpoints.nsfw("boobs"))
        print(await image.to_dict())

asyncio.run(main())

### Discord.py Usage:
import lunarapi

@commands.command()
async def boobs(self, ctx):
    async with aiohttp.ClientSession() as session:
        client = lunarapi.Client(
            session=session,
            token=token,
        )
        image = await client.request(
            lunarapi.endpoints.nsfw("boobs")
        )
        data = await image.to_dict()

        await ctx.send(f"{data['url']}")

The above returns a JSON object:

{
    "id": "boobs_MF2cWkDS7",
    "url": "https://api.lunardev.group/boobs/boobs_MF2cWkDS7.jpg"
}

This endpoint generates a JSON object

HTTP Request

GET https://api.lunardev.group/nsfw/boobs

Returned data

Key Description
id This is what we refer to as the image ID. It is useful for logging and reporting purposes.
url The direct image URL for the image retrieved. You can use this in embeds and whatever else you wish.

Cum

from lunarapi import Client, endpoints
from aiohttp import ClientSession
import asyncio

token = ""  # Replace with your Lunar API Key.

async def main():
    async with ClientSession() as session:
        client = Client(session=session, token=token)

        image = await client.request(endpoints.nsfw("cum"))
        print(await image.to_dict())

asyncio.run(main())

### Discord.py Usage:
import lunarapi

@commands.command()
async def cum(self, ctx):
    async with aiohttp.ClientSession() as session:
        client = lunarapi.Client(
            session=session,
            token=token,
        )
        image = await client.request(
            lunarapi.endpoints.nsfw("cum")
        )
        data = await image.to_dict()

        await ctx.send(f"{data['url']}")

The above returns a JSON object:

{
    "id": "cum_MF2cWkDS7",
    "url": "https://api.lunardev.group/cum/cum_MF2cWkDS7.jpg"
}

This endpoint generates a JSON object

HTTP Request

GET https://api.lunardev.group/nsfw/cum

Returned data

Key Description
id This is what we refer to as the image ID. It is useful for logging and reporting purposes.
url The direct image URL for the image retrieved. You can use this in embeds and whatever else you wish.

Gif

from lunarapi import Client, endpoints
from aiohttp import ClientSession
import asyncio

token = ""  # Replace with your Lunar API Key.

async def main():
    async with ClientSession() as session:
        client = Client(session=session, token=token)

        image = await client.request(endpoints.nsfw("gif"))
        print(await image.to_dict())

asyncio.run(main())

### Discord.py Usage:
import lunarapi

@commands.command()
async def gif(self, ctx):
    async with aiohttp.ClientSession() as session:
        client = lunarapi.Client(
            session=session,
            token=token,
        )
        image = await client.request(
            lunarapi.endpoints.nsfw("gif")
        )
        data = await image.to_dict()

        await ctx.send(f"{data['url']}")

The above returns a JSON object:

{
    "id": "gif_MF2cWkDS7",
    "url": "https://api.lunardev.group/gif/gif_MF2cWkDS7.gif"
}

This endpoint generates a JSON object

HTTP Request

GET https://api.lunardev.group/nsfw/gif

Returned data

Key Description
id This is what we refer to as the image ID. It is useful for logging and reporting purposes.
url The direct image URL for the image retrieved. You can use this in embeds and whatever else you wish.

Hololive

from lunarapi import Client, endpoints
from aiohttp import ClientSession
import asyncio

token = ""  # Replace with your Lunar API Key.

async def main():
    async with ClientSession() as session:
        client = Client(session=session, token=token)

        image = await client.request(endpoints.nsfw("hololive"))
        print(await image.to_dict())

asyncio.run(main())

### Discord.py Usage:
import lunarapi

@commands.command()
async def hololive(self, ctx):
    async with aiohttp.ClientSession() as session:
        client = lunarapi.Client(
            session=session,
            token=token,
        )
        image = await client.request(
            lunarapi.endpoints.nsfw("hololive")
        )
        data = await image.to_dict()

        await ctx.send(f"{data['url']}")

The above returns a JSON object:

{
    "id": "hololive_MF2cWkDS7",
    "url": "https://api.lunardev.group/hololive/hololive_MF2cWkDS7.jpg"
}

This endpoint generates a JSON object

HTTP Request

GET https://api.lunardev.group/nsfw/hololive

Returned data

Key Description
id This is what we refer to as the image ID. It is useful for logging and reporting purposes.
url The direct image URL for the image retrieved. You can use this in embeds and whatever else you wish.

Jpg

from lunarapi import Client, endpoints
from aiohttp import ClientSession
import asyncio

token = ""  # Replace with your Lunar API Key.

async def main():
    async with ClientSession() as session:
        client = Client(session=session, token=token)

        image = await client.request(endpoints.nsfw("jpg"))
        print(await image.to_dict())

asyncio.run(main())

### Discord.py Usage:
import lunarapi

@commands.command()
async def jpg(self, ctx):
    async with aiohttp.ClientSession() as session:
        client = lunarapi.Client(
            session=session,
            token=token,
        )
        image = await client.request(
            lunarapi.endpoints.nsfw("jpg")
        )
        data = await image.to_dict()

        await ctx.send(f"{data['url']}")

The above returns a JSON object:

{
    "id": "jpg_MF2cWkDS7",
    "url": "https://api.lunardev.group/jpg/jpg_MF2cWkDS7.jpg"
}

This endpoint generates a JSON object

HTTP Request

GET https://api.lunardev.group/nsfw/jpg

Returned data

Key Description
id This is what we refer to as the image ID. It is useful for logging and reporting purposes.
url The direct image URL for the image retrieved. You can use this in embeds and whatever else you wish.

Neko

from lunarapi import Client, endpoints
from aiohttp import ClientSession
import asyncio

token = ""  # Replace with your Lunar API Key.

async def main():
    async with ClientSession() as session:
        client = Client(session=session, token=token)

        image = await client.request(endpoints.nsfw("neko"))
        print(await image.to_dict())

asyncio.run(main())

### Discord.py Usage:
import lunarapi

@commands.command()
async def neko(self, ctx):
    async with aiohttp.ClientSession() as session:
        client = lunarapi.Client(
            session=session,
            token=token,
        )
        image = await client.request(
            lunarapi.endpoints.nsfw("neko")
        )
        data = await image.to_dict()

        await ctx.send(f"{data['url']}")

The above returns a JSON object:

{
    "id": "neko_MF2cWkDS7",
    "url": "https://api.lunardev.group/neko/neko_MF2cWkDS7.jpg"
}

This endpoint generates a JSON object

HTTP Request

GET https://api.lunardev.group/nsfw/neko

Returned data

Key Description
id This is what we refer to as the image ID. It is useful for logging and reporting purposes.
url The direct image URL for the image retrieved. You can use this in embeds and whatever else you wish.

Panties

from lunarapi import Client, endpoints
from aiohttp import ClientSession
import asyncio

token = ""  # Replace with your Lunar API Key.

async def main():
    async with ClientSession() as session:
        client = Client(session=session, token=token)

        image = await client.request(endpoints.nsfw("panties"))
        print(await image.to_dict())

asyncio.run(main())

### Discord.py Usage:
import lunarapi

@commands.command()
async def panties(self, ctx):
    async with aiohttp.ClientSession() as session:
        client = lunarapi.Client(
            session=session,
            token=token,
        )
        image = await client.request(
            lunarapi.endpoints.nsfw("panties")
        )
        data = await image.to_dict()

        await ctx.send(f"{data['url']}")

The above returns a JSON object:

{
    "id": "panties_MF2cWkDS7",
    "url": "https://api.lunardev.group/panties/panties_MF2cWkDS7.jpg"
}

This endpoint generates a JSON object

HTTP Request

GET https://api.lunardev.group/nsfw/panties

Returned data

Key Description
id This is what we refer to as the image ID. It is useful for logging and reporting purposes.
url The direct image URL for the image retrieved. You can use this in embeds and whatever else you wish.

Thighs

from lunarapi import Client, endpoints
from aiohttp import ClientSession
import asyncio

token = ""  # Replace with your Lunar API Key.

async def main():
    async with ClientSession() as session:
        client = Client(session=session, token=token)

        image = await client.request(endpoints.nsfw("thighs"))
        print(await image.to_dict())

asyncio.run(main())

### Discord.py Usage:
import lunarapi

@commands.command()
async def thighs(self, ctx):
    async with aiohttp.ClientSession() as session:
        client = lunarapi.Client(
            session=session,
            token=token,
        )
        image = await client.request(
            lunarapi.endpoints.nsfw("thighs")
        )
        data = await image.to_dict()

        await ctx.send(f"{data['url']}")

The above returns a JSON object:

{
    "id": "thighs_MF2cWkDS7",
    "url": "https://api.lunardev.group/thighs/thighs_MF2cWkDS7.jpg"
}

This endpoint generates a JSON object

HTTP Request

GET https://api.lunardev.group/nsfw/thighs

Returned data

Key Description
id This is what we refer to as the image ID. It is useful for logging and reporting purposes.
url The direct image URL for the image retrieved. You can use this in embeds and whatever else you wish.

Yuri

from lunarapi import Client, endpoints
from aiohttp import ClientSession
import asyncio

token = ""  # Replace with your Lunar API Key.

async def main():
    async with ClientSession() as session:
        client = Client(session=session, token=token)

        image = await client.request(endpoints.nsfw("yuri"))
        print(await image.to_dict())

asyncio.run(main())

### Discord.py Usage:
import lunarapi

@commands.command()
async def yuri(self, ctx):
    async with aiohttp.ClientSession() as session:
        client = lunarapi.Client(
            session=session,
            token=token,
        )
        image = await client.request(
            lunarapi.endpoints.nsfw("yuri")
        )
        data = await image.to_dict()

        await ctx.send(f"{data['url']}")

The above returns a JSON object:

{
    "id": "yuri_MF2cWkDS7",
    "url": "https://api.lunardev.group/yuri/yuri_MF2cWkDS7.jpg"
}

This endpoint generates a JSON object

HTTP Request

GET https://api.lunardev.group/nsfw/yuri

Returned data

Key Description
id This is what we refer to as the image ID. It is useful for logging and reporting purposes.
url The direct image URL for the image retrieved. You can use this in embeds and whatever else you wish.

Errors

The Lunar API uses the following error codes:

Error Code Meaning
400 Bad Request -- Your request is invalid.
401 Unauthorized -- Your API key is wrong.
403 Forbidden -- The endpoint requested is hidden for administrators only.
404 Not Found -- The specified endpoint could not be found.
405 Method Not Allowed -- You tried to access an endpoint with an invalid method.
406 Not Acceptable -- You requested a format that isn't json.
410 Gone -- The endpoint requested has been removed from our servers.
418 I'm a teapot.
429 Too Many Requests -- You're requesting too many things! Slow down!
500 Internal Server Error -- We had a problem with our server. Try again later.
503 Service Unavailable -- We're temporarily offline for maintenance. Please try again later.