Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hansyagarwal/news-api

News-API for Appointy online test
https://github.com/hansyagarwal/news-api

api golang postman

Last synced: about 2 months ago
JSON representation

News-API for Appointy online test

Awesome Lists containing this project

README

        

# news-api

## Requirements
- Postman
- Go ver 1.4 or later
- Text editor (VSCode recommended)

## What operations it can do?
- Create an Article
- Get an Article by it's id
- List/Get all the Articles
- Search for an artice by it's title,subtitle or content

## How to run?
import/download all package and libraries using `go get`
```
go run main.go
```
> port: 3000

> everything is case-sensitive

> the mongodb uri is kept public for some time

open postman and create new request

### for creating an article,
switch from GET to POST and type `localhost:3000/articles`
select `body` and then `raw` and for example type
```
{
"Title": "news article",
"Subtitle": "subtitle of new article",
"Content": "content of new article"
}
```
click send

### for other operations,
switch to GET and type:
`localhost:3000/articles` to list all the articles

`localhost:3000/articles/` to get the article by its id (try `5fa96b181aff7c9b9bb04e8a` as id or put `localhost:3000/articles/5fa96b181aff7c9b9bb04e8a`)

`localhost:3000/articles/search?q=` to get the article by its title/subtitle/content (if the title is more than 1 word use `%20` for space, eg: `localhost:3000/articles/search?q=Covid19%20vaccine`)