Coder Social home page Coder Social logo

image-api's Introduction

Image API

Setup

Make sure to set the IMAGGA_API_KEY, IMAGGA_API_SECRET, and DATABASE_URL environmental variables first.

The DATABASE_URL environmental variable should look something like:

postgres://username:password@localhost/image-api

Be sure to create the image-api database in Postgresql first so the migrations can run properly:

CREATE DATABASE image-api;

or using the command:

createdb image-api

Build & run

After performing the setup above, you can build and run by doing the following:

rustup default nightly   # recommended
cargo run

API reference

Uploading an image

Images can be uploaded via POST /images with the following JSON body:

{
    "image_url": "<your image url>",
    "object_detection": true,
    "label": "<omit this field to autogenerate a label>"
}

Alternatively, you can instead upload an image by base64 encoding it:

{
    "image_base64": "<your base64-encoded image>",
    ...
}

Note that including both image_url and image_base64 in a request will result in a 400 Bad Request error.

Querying images

Query an image by id:

GET /images/{imageId}

Query all images:

GET /images

Query all images that contain all of the provided tags:

GET /images?objects=dog,cat

Bonus: query all images that contain one or more of the provided tags:

GET /images?some_objects=dog,cat

Response format

GET /images/{imageID} and POST /images will return a single image. All other endpoints will return an array of images. Returned images have the following format:

{
    "url": "<url you provided, or where a base64-encoded image was uploaded to>",
    "tags": [
        "tag1",
        "tag2",
        ...
    ],
    "label": "<a label you provided, or one that was generated for you>",
    "id": "<the image's id>"
}

image-api's People

Contributors

jmoore34 avatar

Watchers

 avatar

image-api's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.