Skip to content

elizandrodantas/news-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NEWS-API 🗽

project searches for articles in some Brazilian news sites;

designed for educational purposes. any copyright infringement, contact;

Sources used in code 🌎

  • G1
  • R7
  • EL PAIS BRAZIL

Table of contents

Install

npm install

#or

yarn install

Endpoint ☕

Authorization - v0.1

curl --request POST \
  --url http:https://localhost:8080/v1/auth \
  --header 'Content-Type: application/json' \
  --data '{
	"password": "admin",
	"username": "admin"
}'

Register - v0.1

  curl --request POST \
  --url http:https://localhost:8080/v1/register \
  --header 'Content-Type: application/json' \
  --data '{
	"name": "name",
	"lastname": "last",
	"password": "admin",
	"username": "admin",
	"email": "[email protected]",
	"cell": "11900000000"
}'

Check if parameters are already registered - v0.1

username

  curl --request GET \
  --url http:https://localhost:8080/v1/register/user/{username} \
  --header 'Content-Type: application/json'

email

  curl --request GET \
  --url http:https://localhost:8080/v1/register/email/{email} \
  --header 'Content-Type: application/json'

cellphone

  curl --request GET \
  --url http:https://localhost:8080/v1/register/cellphone/{cellphone} \
  --header 'Content-Type: application/json'

Refresh token - v0.1

  curl --request GET \
  --url http:https://localhost:8080/v1/auth/refresh \
  --header 'Authorization: Bearer {token}'

User info - v0.1

 curl --request GET \
  --url http:https://localhost:8080/v1/user \
  --header 'Authorization: Bearer {token}' \
  --header 'Content-Type: application/json'

Confirm email - v0.1

curl --request POST \
  --url http:https://localhost:8080/v1/user/email/c \
  --header 'Content-Type: application/json' \
  --data '{
	"code": "{code}"
	"id": "{userId}
}'

Get user info (not required authorization) - v0.1

  curl --request GET \
  --url http:https://localhost:8080/v1/auth/u/{username} \
  --header 'Content-Type: application/json'

Re-send email confirmation - v0.1

  curl --request GET \
  --url http:https://localhost:8080/v1/user/email/send \
  --header 'Authorization: Bearer {token}' \
  --header 'Content-Type: application/json'

NEWS - List Articles

GET

  curl --request GET \
  --url 'http:https://localhost:8080/v1/api/news/list?{options}' \
  --header 'Authorization: Bearer {token}' \
  --header 'Content-Type: application/json'

POST

  curl --request POST \
  --url 'http:https://localhost:8080/v1/api/news/list' \
  --header 'Authorization: Bearer {token}'
  --header 'Content-Type: application/json' \
  --data '{options}'

SEARSH OPTIONS (* required)

  • category: string (search for categories in endpoint)
  • intitle: string (word search in title)
  • limit: number | null
  • source: "r7" | "g1" | "elpais" (comma separated for results from more than one source)

NEWS - List Categories

  curl --request GET \
  --url 'http:https://localhost:8080/v1/api/news/category?{options}' \
  --header 'Authorization: Bearer {token}'

SEARSH OPTIONS (* required)

  • source: "r7" | "g1" | "elpais" (comma separated for results from more than one source)

NEWS - Create Storage

curl --request GET \
  --url http:https://localhost:8080/v1/api/news/storage/add/{id_article} \
  --header 'Authorization: Bearer {token}'

Article id is found in the result of article list endpoint

NEWS - Content Article

  curl --request GET \
  --url http:https://localhost:8080/v1/api/news/content/{id} \
  --header 'Authorization: Bearer {token}'

**{id} found in storage response or article list response

WORDPRESS - Create Service

  curl --request POST \
  --url http:https://localhost:8080/v1/api/wordpress/add/ \
  --header 'Authorization: Bearer {token}' \
  --header 'Content-Type: application/json' \
  --data '{
	"url": "{url}",
	"username": "{username}",
	"password": "{password}"
}'

OPTIONS (* required)

  • *{url}: string (url wordpress system)
  • *{username}: string (username using login in portal admin)
  • *{password}: string (password using login in portal admin)

PLUGIN REQUIRED

  • JWT AUTH

RECOMENDED: JWT Authentication for WP REST API

WORDPRESS - List Services

  curl --request GET \
  --url http:https://localhost:8080/v1/api/wordpress \
  --header 'Authorization: Bearer {token}'

WORDPRESS - List Categories

curl --request GET \
  --url http:https://localhost:8080/v1/api/wordpress/get/category/{service_id} \
  --header 'Authorization: Bearer {token}'

{service_id} found in list services

WORDPRESS - Add categories

  curl --request POST \
  --url http:https://localhost:8080/v1/api/wordpress/add/category/{service_id} \
  --header 'Authorization: Bearer {token}' \
  --header 'Content-Type: application/json' \
  --data '{
	"name": string[],
	"description": string[]
}'

{service_id} found in list services

WORDPRESS - List Tags

 curl --request GET \
  --url http:https://localhost:8080/v1/api/wordpress/get/tags/{service_id} \
  --header 'Authorization: Bearer {token}'

{service_id} found in list services

WORDPRESS - Add Tags

 curl --request POST \
  --url http:https://localhost:8080/v1/api/wordpress/add/tag/{service_id} \
  --header 'Authorization: Bearer {token}' \
  --header 'Content-Type: application/json' \
  --data '{
	"name": string[],
	"description": string[]
}'

{service_id} found in list services

WORDPRESS - Add Media

curl --request POST \
  --url http:https://localhost:8080/v1/api/wordpress/add/media/{service_id} \
  --header 'Authorization: Bearer {token}' \
  --header 'Content-Type: application/json' \
  --data '{
	"description": {description},
	"caption": "{caption}",
	"url": "{url}",
	"status": "{status}"
}'

OPTIONS (* required)

  • *{url}: string (url image send wordpress)
  • {description}: string (description image)
  • {caption}: string (caption image)
  • {status}: "publish" | "pending" (default: pending)

{service_id} found in list services {url} found in content

WORDPRESS - Create Post

  curl --request POST \
  --url http:https://localhost:8080/v1/api/wordpress/add/post/{service_id} \
  --header 'Authorization: Bearer {token}' \
  --header 'Content-Type: application/json' \
  --data '{
	"status": "{status}",
	"category": {category},
	"id": "{id}",
	"media_id": {media_id}
}'

OPTIONS (* required)

  • {status}: "publish" | "future" | "pending" | "private" (default: pending)
  • {password}: string (required if {status} is private)
  • {category}: number[] (array categories id)
  • *{id}: string (found in storage response or article list response)
  • {media_id}: number (id featured image)

{service_id} found in list services

WORDPRESS - Job details

curl --request GET \
  --url http:https://localhost:8080/v1/api/wordpress/job/{job_id} \
  --header 'Authorization: Bearer {token}'

{job_id} found in response created post

WORDPRESS - List all jobs

curl --request GET \
  --url http:https://localhost:8080/v1/api/wordpress/report/{service_id} \
  --header 'Authorization: Bearer {token}'

{service_id} found in list services

WORDPRESS - Status sources

curl --request GET \
  --url http:https://localhost:8080/v1/api/wordpress/status \
  --header 'Authorization: Bearer {token}'

ADMIN - User (permission required)

list all user

curl --request GET \
  --url http:https://localhost:8080/v1/admin/user/list \
  --header 'Authorization: Bearer {token}'

user details

curl --request GET \
  --url http:https://localhost:8080/v1/admin/user/{userId} \
  --header 'Authorization: Bearer {token}'

add user

 curl --request POST \
  --url http:https://localhost:8080/v1/admin/user/add \
  --header 'Authorization: Bearer {token}' \
  --header 'Content-Type: application/json' \
  --data '{
	"name": "{name}",
	"username": "{username}",
	"password": "{password}",
	"cell": "{cell}",
	"email": "{email}",
	"lastname": "{lastname}"
}'

block user

curl --request PUT \
  --url http:https://localhost:8080/v1/admin/user/block \
  --header 'Authorization: Bearer {token}' \
  --header 'Content-Type: application/json' \
  --data '{
	"id": "{userId}"
}'

unlock user

curl --request PUT \
  --url http:https://localhost:8080/v1/admin/user/unlock \
  --header 'Authorization: Bearer {token}' \
  --header 'Content-Type: application/json' \
  --data '{
	"id": "{userId}"
}'

edit user

curl --request PUT \
  --url http:https://localhost:8080/v1/admin/user/edit \
  --header 'Authorization: Bearer {token}' \
  --header 'Content-Type: application/json' \
  --data '{
	"id": "{userId}",
	"name": "{name}",
	"lastname": "{lastname}",
	"cellphone": "{cell}",
	"email": "{email}",
}'

remove user

curl --request DELETE \
  --url http:https://localhost:8080/v1/admin/user/remove \
  --header 'Authorization: Bearer {userId}' \
  --header 'Content-Type: application/json' \
  --data '{
	"id": "{userId}"
}'

ADMIN - ACL (required permission)

list permission user

curl --request GET \
  --url http:https://localhost:8080/v1/admin/acl/list/user/{userId} \
  --header 'Authorization: Bearer {token}'

add permission user

curl --request POST \
  --url http:https://localhost:8080/v1/admin/acl/add/user \
  --header 'Authorization: Bearer {token}' \
  --header 'Content-Type: application/json' \
  --data '{
	"user_id": "{userId}",
	"permission_id": "{permissionId}"
}'

remove permission user

curl --request DELETE \
  --url http:https://localhost:8080/v1/admin/acl/remove/user \
  --header 'Authorization: Bearer {token}' \
  --header 'Content-Type: application/json' \
  --data '{
	"user_id": "{userId}",
	"permission_id": "{permissionId}"
}'

ADMIN - Permission (required permission)

list permissions

curl --request GET \
  --url http:https://localhost:8080/v1/admin/permission/list \
  --header 'Authorization: Bearer {token}'

add permission

curl --request POST \
  --url http:https://localhost:8080/v1/admin/permission/add \
  --header 'Authorization: Bearer {token}' \
  --header 'Content-Type: application/json' \
  --data '{
	"name": "{name}",
	"description": "{description}"
}'

Contact

This is an image @elizandrodantas

back to top