Describes a NewsItem.
Field | Type | Description |
---|---|---|
id |
number |
Unique ID |
title |
string |
- |
url |
string |
- |
source |
string |
Provider |
language |
string |
Language: en , es . |
body |
string |
Short description |
image |
string |
Representative image URL |
Describes a User.
Field | Type | Description |
---|---|---|
id |
number |
Unique ID |
name |
string |
- |
username |
string |
Primary key of users |
email |
string |
- |
Describes a Tag. News have many tags.
Field | Type | Description |
---|---|---|
id |
number |
Unique ID |
name |
string |
Tag name |
Describes a Category. News belongs to one category.
Field | Type | Description |
---|---|---|
id |
number |
Unique ID |
name |
string |
Category name |
Describes a Person. News are related with many people.
Field | Type | Description |
---|---|---|
id |
number |
Unique ID |
name |
string |
Person name |
Describes a Location. News belongs to one location.
Field | Type | Description |
---|---|---|
id |
number |
Unique ID |
name |
string |
Location name |
Describes NewsItem
source. NewsItem has one NewsProvider
Field | Type | Description |
---|---|---|
id |
number |
Unique ID |
name |
string |
News Provider name |
Creates an account.
Argument | Type | Description |
---|---|---|
name |
string |
- |
username |
string |
- |
email |
string |
- |
password |
string |
- |
This returns the account session token
Argument | Type | Description |
---|---|---|
token |
string |
Access token |
Re-new expired token
Argument | Type | Description |
---|---|---|
username |
string |
- |
password |
string |
- |
This returns the account session token
Argument | Type | Description |
---|---|---|
token |
string |
Access token |
Each requests must include a valid non-expired
Bearer <token>
asAuthentication
header. Otherwise will return a401 Unauthorized
status code.
Returns a NewsItem
's list
Argument | Type | Default | Description |
---|---|---|---|
page |
uint |
0 |
Page number |
Returns the NewsItem
associated with that id
Search NewsItem
with:
Argument | Type | Default | Description |
---|---|---|---|
page |
uint |
0 |
Page number |
tags |
[]string |
Filter by Tag 's name |
|
providers |
[]string |
Filter by NewsProvider 's name |
|
locations |
[]string |
Search news in this locations | |
people |
[]string |
Search news related with | |
categories |
[]string |
Filter by Categories name |
.../api/v1/private/news?tags=love&tags=kill&providers=cnn&providers=emol&people=name&categories=national
Returns a Tag
's list
Returns a NewsProvider
's list
Returns a Category
's list
Returns a Person
's list
Returns a Location
's list
Install Golang.
Make sure to configure $GOPATH
. For example:
$ export GOPATH=$HOME/Repositories/go
$ export PATH=$PATH:$GOPATH/bin
Get this repository using go
:
$ go get github.com/tools/godep
$ go get github.com/IIC2173-2015-2-Grupo2/news-api
# Project directory
$ cd $GOPATH/src/github.com/IIC2173-2015-2-Grupo2/news-api/
Setup database
# Example values
export NEO4J_HOST="192.168.99.100"
export NEO4J_PORT="7474"
export NEO4J_USER="neo4j"
export NEO4J_PASS="neo4j"
export ANALYTICS_TOKEN="GOOGLE_ANALYTICS_TOKEN"
Setup other environment variables
export ENVIRONMENT="PRODUCTION"
export SECRET_HASH="SECRET_HASH"
export AUTH="ENABLE"
export LOADER_IO_TOKEN="IO_TOKEN"
Build and run the project locally using:
$ make start
Build and run:
$ docker-compose up -d
Log to postgres container:
$ docker exec -it newsapi_db_1 /bin/bash
Log to postgres service:
$ psql -U postgres
Create Database
CREATE DATABASE newsapi;