Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gojibjib/jibjib-api
Go REST API for communication between the app and query service
https://github.com/gojibjib/jibjib-api
docker docker-image golang rest-api saltstack terraform
Last synced: 3 months ago
JSON representation
Go REST API for communication between the app and query service
- Host: GitHub
- URL: https://github.com/gojibjib/jibjib-api
- Owner: gojibjib
- License: gpl-3.0
- Created: 2018-05-11T16:12:18.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-11-03T14:28:45.000Z (about 6 years ago)
- Last Synced: 2024-09-30T13:41:48.021Z (3 months ago)
- Topics: docker, docker-image, golang, rest-api, saltstack, terraform
- Language: Go
- Homepage:
- Size: 2.13 MB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# [jibjib-api](https://github.com/gojibjib/jibjib-api)
[![Go Report Card](https://goreportcard.com/badge/github.com/gojibjib/gopeana)](https://goreportcard.com/report/github.com/gojibjib/jibjib-api) [![Docker Build Status](https://img.shields.io/docker/build/obitech/jibjib-api.svg)](https://hub.docker.com/r/obitech/jibjib-api/builds/)
[![godoc reference](https://img.shields.io/badge/godoc-reference-blue.svg)](https://godoc.org/github.com/gojibjib/jibjib-api/pkg/api)Go REST API to receive input from the [JibJib Android App](https://github.com/gojibjib/jibjib), [query](https://github.com/gojibjib/jibjib-query) the [model](https://github.com/gojibjib/jibjib-model) and send those information back to the App.
## Repo layout
The complete list of JibJib repos is:- [jibjib](https://github.com/gojibjib/jibjib): Our Android app. Records sounds and looks fantastic.
- [deploy](https://github.com/gojibjib/deploy): Instructions to deploy the JibJib stack.
- [jibjib-model](https://github.com/gojibjib/jibjib-model): Code for training the machine learning model for bird classification
- [jibjib-api](https://github.com/gojibjib/jibjib-api): Main API to receive database requests & audio files.
- [jibjib-data](https://github.com/gojibjib/jibjib-data): A MongoDB instance holding information about detectable birds.
- [jibjib-query](https://github.com/gojibjib/jibjib-query): A thin Python Flask API that handles communication with the [TensorFlow Serving](https://www.tensorflow.org/serving/) instance.
- [gopeana](https://github.com/gojibjib/gopeana): A API client for [Europeana](https://europeana.eu), written in Go.
- [voice-grabber](https://github.com/gojibjib/voice-grabber): A collection of scripts to construct the dataset required for model training## Install
### Docker
See [deploy instructions](https://github.com/gojibjib/deploy).### Compile yourself
If you didn't clone the repo, `go get` the package and the `main.go`:```
go get github.com/gojibjib/jibjib-api/pkg
cd $GOPATH/src/github.com/gojibjib/jibjib-api
wget https://raw.githubusercontent.com/gojibjib/jibjib-api/master/meta/main.go
```Compile it:
```
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .
```Setup [jibjib-data](https://github.com/gojibjib/jibjib-data).
Start the API:
```
export JIBJIB_DB_URL=read:read@localhost/birds
./app
```## API Documentation
### EndpointsEndpoint|Method|Comment
---|---|---
`/`|GET|Answers with a basic "Pong" response
`/ping`|GET|Answers with a basic "Pong" response
`/birds/dummy`|GET|Sends a JSON Response with randomized IDs and accuracies for testing
`/birds/all`|GET|Retrieves all bird information, without descriptions
`/birds/{id:[0-9]+}`|GET|Retrieves bird information by ID. Use query string `desc_de=false` and `desc_en=false` to omit description fields.
`/detect/binary`|POST|Send a MP4 file to the API to start querying the ML model for bird voice recognition. File needs to be send in binary format and with the Header `Content-Type: application/octet-stream` set.### Response format
```
{
"status": ,
"message": ,
"count": ,
"data": {...} | null
}
```### Examples
```
curl "http://localhost:8080/ping"
{
"status":200,
"message":"Pong",
"count":0,
"data":null
}
``````
curl "htttp://localhost:8080/birds/1"
{
"status":200,
"message":"Bird found",
"count":1,
"data": {
"id":1,
"name":"Cuculus canorus",
"genus":"Cuculus",
"species":"canorus",
"title_de":"Kuckuck",
"title_en":"Common cuckoo",
"desc_de":"...omitted...",
"desc_en":"...omitted..."
}
}
``````
curl "htttp://localhost:8080/birds/1?desc_de=false&desc_en=false"
{
"status":200,
"message":"Bird found",
"count":1,
"data": {
"id":1,
"name":"Cuculus canorus",
"genus":"Cuculus",
"species":"canorus",
"title_de":"Kuckuck",
"title_en":"Common cuckoo",
"desc_de":"",
"desc_en":""
}
}
``````
# For now, only mp4 files are being accepted
curl -H 'Content-Type: application/octet-stream' -X POST --data-binary @larus_canus_3.mp4 http://localhost:8081/detect/binary
{
"message": "Detection successful",
"status": 200,
"count": 3,
"data": [
{
"accuracy": 0.6470588235294118,
"id": 110
},
{
"accuracy": 0.17647058823529413,
"id": 7
},
{
"accuracy": 0.17647058823529413,
"id": 30
}
]
}
```