NOTE: Please note that the web app is not ready. However, you can use Postman or any other REST client.
List of APIs exposed
Before you can fetch news, you have to create an account.
Create an account
```typescript const BASE_URL = 'https://news-scraper-0fmx.onrender.com/api/v1/' ```POST /auth/signup
Headers: 'Content-Type: application/json'
Body: {
email: "string",
isPublic: true
}
Response
// This is the response object
interface ISignUpResponse {
statusCode: number;
isSuccess: boolean;
message: string;
}
{
"statusCode": 200,
"isSuccess": true,
"message": "User created"
}
{
"isSuccess": false,
"message": "Please provide email"
}
{
"statusCode": 500,
"isSuccess": false,
"message": "Internal Server Error"
}
{
"statusCode": 405,
"isSuccess": false,
"message": "Method not allowed"
}
const fetch = require('node-fetch');
const apiUrl = "https://news-scraper-0fmx.onrender.com/api/v1/auth/signup";
const body = {
"email": "email@email.com",
"isPublic": true
};
fetch(apiUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(body)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import requests
import json
api_url = "https://news-scraper-0fmx.onrender.com/api/v1/auth/signup"
body = {
"email": "email@email.com",
"isPublic": true
};
headers = {
"Content-Type": "application/json"
}
response = requests.post(api_url, headers=headers, data=json.dumps(body))
if response.status_code == 201:
data = response.json()
print(data)
else:
print(f"Error: {response.status_code}")
package main
import (
"fmt"
"net/http"
"io/ioutil"
"bytes"
)
func main() {
apiURL := "https://news-scraper-0fmx.onrender.com/api/v1/auth/signup"
body := []byte(`{"email":"email@email.com", "isPublic":true}`)
req, err := http.NewRequest("POST", apiURL, bytes.NewBuffer(body))
if err != nil {
fmt.Println("Error creating request:", err)
return
}
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error sending request:", err)
return
}
defer resp.Body.Close()
respBody, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response:", err)
return
}
fmt.Println(string(respBody))
}
After you've created your account, please verify your account and you'll be signed in
Account verification
# Account Verification and Token GenerationPOST /auth/verify
Headers: Content-Type: application/json
Body: {
"email": "string",
"verifyCode": "number"
}
Response
// This is the response object
interface IVerifyResponse {
statusCode: number;
isSuccess: boolean;
message: string;
token?: string;
}
{
"statusCode": 200,
"isSuccess": true,
"message": "Successfully signed in."
}
{
"isSuccess": false,
"message": "Please provide required body params"
}
{
"statusCode": 500,
"isSuccess": false,
"message": "Internal Server Error"
}
{
"statusCode": 405,
"isSuccess": false,
"message": "Method not allowed"
}
const fetch = require('node-fetch');
const apiUrl = "https://news-scraper-0fmx.onrender.com/api/v1/auth/verify";
const body = {
email: "email@email.com",
verifyCode: 1234
};
fetch(apiUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(body)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import requests
import json
api_url = "https://news-scraper-0fmx.onrender.com/api/v1/auth/verify"
body = {
"email": "email@email.com",
"verifyCode": 1234
}
headers = {
"Content-Type": "application/json"
}
response = requests.post(api_url, headers=headers, data=json.dumps(body))
if response.status_code == 200:
data = response.json()
print(data)
else:
print(f"Error: {response.status_code}")
package main
import (
"fmt"
"net/http"
"io/ioutil"
"bytes"
)
func main() {
apiURL := "https://news-scraper-0fmx.onrender.com/api/v1/auth/verify"
body := []byte(`{"email":"email@email.com", "verifyCode":1234}`)
req, err := http.NewRequest("POST", apiURL, bytes.NewBuffer(body))
if err != nil {
fmt.Println("Error creating request:", err)
return
}
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error sending request:", err)
return
}
defer resp.Body.Close()
respBody, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response:", err)
return
}
fmt.Println(string(respBody))
}
After you've verified your account, you can sign in and get your authentication token to get token to create API Key
Sign In
# Sign InPOST /auth/signin
Headers: Content-Type: application/json
Body: {
"email": "string"
}
Response
// This is the response object
interface ISignInResponse {
statusCode: number;
isSuccess: boolean;
message: string;
}
{
"statusCode": 200,
"isSuccess": true,
"message": "Verification code has been sent."
}
{
"isSuccess": false,
"message": "Please provide email"
}
{
"statusCode": 500,
"isSuccess": false,
"message": "Internal Server Error"
}
{
"statusCode": 405,
"isSuccess": false,
"message": "Method not allowed"
}
const fetch = require('node-fetch');
const apiUrl = "https://news-scraper-0fmx.onrender.com/api/v1/auth/signin";
const body = {
"email": "email@email.com"
};
fetch(apiUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(body)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import requests
import json
api_url = "https://news-scraper-0fmx.onrender.com/api/v1/auth/signin"
body = {
"email": "email@email.com"
}
headers = {
"Content-Type": "application/json"
}
response = requests.post(api_url, headers=headers, data=json.dumps(body))
if response.status_code == 200:
data = response.json()
print(data)
else:
print(f"Error: {response.status_code}")
package main
import (
"fmt"
"net/http"
"io/ioutil"
"bytes"
)
func main() {
apiURL := "https://news-scraper-0fmx.onrender.com/api/v1/auth/signin"
body := []byte(`{"email":"email@email.com"}`)
req, err := http.NewRequest("POST", apiURL, bytes.NewBuffer(body))
if err != nil {
fmt.Println("Error creating request:", err)
return
}
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error sending request:", err)
return
}
defer resp.Body.Close()
respBody, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response:", err)
return
}
fmt.Println(string(respBody))
}
After you've signed in, you can get your authentication token to create API Key
Create API Key
# Create API KeyPOST /api/v1/apikey
Headers:
Content-Type: application/json
authorizationtoken: 'string'
Response
// This is the response object
interface ICreateAPIKeyResponse {
success: boolean;
message: string;
apiKeyData?: {
apiKey: string;
};
}
{
"success": true,
"message": "API Key created.",
"apiKeyData": {
"apiKey": "some api key"
}
}
{
"message": "Authentication token expired",
"isSuccess": false
}
{
"statusCode": 500,
"isSuccess": false,
"message": "Internal Server Error"
}
{
"statusCode": 405,
"isSuccess": false,
"message": "Method not allowed"
}
const fetch = require('node-fetch');
const apiUrl = "https://news-scraper-0fmx.onrender.com/api/v1/apikey";
fetch(apiUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'authorizationtoken': 'sometoken'
}
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import requests
import json
api_url = "https://news-scraper-0fmx.onrender.com/api/v1/apikey"
headers = {
"Content-Type": "application/json",
"authorizationtoken": "sometoken"
}
response = requests.post(api_url, headers=headers)
if response.status_code == 200:
data = response.json()
print(data)
else:
print(f"Error: {response.status_code}")
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
apiURL := "https://news-scraper-0fmx.onrender.com/api/v1/apikey"
req, err := http.NewRequest("POST", apiURL, nil)
if err != nil {
fmt.Println("Error creating request:", err)
return
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("authorizationtoken", "sometoken")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error sending request:", err)
return
}
defer resp.Body.Close()
respBody, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response:", err)
return
}
fmt.Println(string(respBody))
}
If you forgot your API Key, you can get it by signing in and retrieving your API Key.
Get API Key
# Retrieve API KeyGET /api/v1/apikey
Headers:
Content-Type: application/json
authorizationtoken: 'string'
Response
// This is the response object
interface IRetrieveAPIKeyResponse {
success: boolean;
message: string;
apiKeyData?: {
apiKey: string;
userId: string;
createdAt: number;
updatedAt: number;
};
}
{
"success": true,
"message": "API Key retrieved",
"apiKeyData": {
"apiKey": "someAPIKey",
"userId": "userId",
"createdAt": 1708775942,
"updatedAt": 1708775942
}
}
{
"message": "Authentication token expired",
"isSuccess": false
}
{
"statusCode": 500,
"isSuccess": false,
"message": "Internal Server Error"
}
{
"statusCode": 405,
"isSuccess": false,
"message": "Method not allowed"
}
const fetch = require('node-fetch');
const apiUrl = "https://news-scraper-0fmx.onrender.com/api/v1/apikey";
fetch(apiUrl, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'authorizationtoken': 'sometoken'
}
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import requests
import json
api_url = "https://news-scraper-0fmx.onrender.com/api/v1/apikey"
headers = {
"Content-Type": "application/json",
"authorizationtoken": "sometoken"
}
response = requests.get(api_url, headers=headers)
if response.status_code == 200:
data = response.json()
print(data)
else:
print(f"Error: {response.status_code}")
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
apiURL := "https://news-scraper-0fmx.onrender.com/api/v1/apikey"
req, err := http.NewRequest("GET", apiURL, nil)
if err != nil {
fmt.Println("Error creating request:", err)
return
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("authorizationtoken", "sometoken")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error sending request:", err)
return
}
defer resp.Body.Close()
respBody, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response:", err)
return
}
fmt.Println(string(respBody))
}
If you would like to delete your API Key.
Delete API Key
# Delete API KeyDELETE /api/v1/apikey
Headers:
Content-Type: application/json
authorizationtoken: 'string'
Response
// This is the response object
interface IDeleteAPIKeyResponse {
statusCode: number;
isSuccess: boolean;
message: string;
}
{
"statusCode": 200,
"isSuccess": true,
"message": "API Key deleted"
}
{
"message": "Authentication token expired",
"isSuccess": false
}
{
"statusCode": 400,
"isSuccess": false,
"message": "API Key does not exists."
}
{
"statusCode": 500,
"isSuccess": false,
"message": "Internal Server Error"
}
{
"statusCode": 405,
"isSuccess": false,
"message": "Method not allowed"
}
const fetch = require('node-fetch');
const apiUrl = "https://news-scraper-0fmx.onrender.com/api/v1/apikey";
fetch(apiUrl, {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
'authorizationtoken': 'sometoken'
}
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import requests
import json
api_url = "https://news-scraper-0fmx.onrender.com/api/v1/apikey"
headers = {
"Content-Type": "application/json",
"authorizationtoken": "sometoken"
}
response = requests.delete(api_url, headers=headers)
if response.status_code == 200:
data = response.json()
print(data)
else:
print(f"Error: {response.status_code}")
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
apiURL := "https://news-scraper-0fmx.onrender.com/api/v1/apikey"
req, err := http.NewRequest("DELETE", apiURL, nil)
if err != nil {
fmt.Println("Error creating request:", err)
return
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("authorizationtoken", "sometoken")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error sending request:", err)
return
}
defer resp.Body.Close()
respBody, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response:", err)
return
}
fmt.Println(string(respBody))
}
If you want to update your API Key.
Update API Key
# Update API KeyPATCH /api/v1/apikey
Headers:
Content-Type: application/json
authorizationtoken: 'string'
Response
// This is the response object
interface IUpdateAPIKeyResponse {
success: boolean;
message: string;
}
{
"success": true,
"message": "API Key updated"
}
{
"message": "Authentication token expired",
"isSuccess": false
}
{
"statusCode": 400,
"isSuccess": false,
"message": "API Key does not exists."
}
{
"statusCode": 500,
"isSuccess": false,
"message": "Internal Server Error"
}
{
"statusCode": 405,
"isSuccess": false,
"message": "Method not allowed"
}
const fetch = require('node-fetch');
const apiUrl = "https://news-scraper-0fmx.onrender.com/api/v1/apikey";
fetch(apiUrl, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
'authorizationtoken': 'sometoken'
}
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import requests
import json
api_url = "https://news-scraper-0fmx.onrender.com/api/v1/apikey"
headers = {
"Content-Type": "application/json",
"authorizationtoken": "sometoken"
}
response = requests.patch(api_url, headers=headers)
if response.status_code == 200:
data = response.json()
print(data)
else:
print(f"Error: {response.status_code}")
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
apiURL := "https://news-scraper-0fmx.onrender.com/api/v1/apikey"
req, err := http.NewRequest("PATCH", apiURL, nil)
if err != nil {
fmt.Println("Error creating request:", err)
return
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("authorizationtoken", "sometoken")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error sending request:", err)
return
}
defer resp.Body.Close()
respBody, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response:", err)
return
}
fmt.Println(string(respBody))
}
Get news types
Get News Types
# Get News TypeGET /news-type
Headers: news_api_key: "API_KEY"
Content-Type: application/json
Response
// This is the response object
interface INewsType {
typeId: string;
type: string;
}
statusCode: number;
isSuccess: boolean;
message: string;
type: Array<INewsType>
{
"statusCode": 200,
"isSuccess": true,
"message": "Successfully retrieved news type",
"type":
[
{
"typeId": "f60391c2-eef6-451b-8609-f1ce39abf05b",
"type": "NSW News"
},
{
"typeId": "c8380049-fc85-487a-993b-c9815478eb00",
"type": "FIFA Women's World Cup™"
},
]
}
{
"statusCode": 404,
"isSuccess": false,
"message": "No news type found"
}
{
"statusCode": 403,
"isSuccess": false,
"message": "Forbidden"
}
{
"statusCode": 500,
"isSuccess": false,
"message": "Internal Server Error"
}
{
"statusCode": 405,
"isSuccess": false,
"message": "Method not allowed"
}
const fetch = require('node-fetch');
const apiKey = "API_KEY";
const apiUrl = "https://news-scraper-0fmx.onrender.com/api/v1/news/news-type";
fetch(apiUrl, {
method: 'GET',
headers: {
'news_api_key': apiKey,
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import requests
api_url = "https://news-scraper-0fmx.onrender.com/api/v1/news/news-type"
api_key = "API_KEY"
headers = {
"news_api_key": api_key,
"Content-Type": "application/json"
}
response = requests.get(api_url, headers=headers)
if response.status_code == 200:
data = response.json()
print(data)
else:
print(f"Error: {response.status_code}")
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
apiURL := "https://news-scraper-0fmx.onrender.com/api/v1/news/news-type"
apiKey := "API_KEY"
req, err := http.NewRequest("GET", apiURL, nil)
if err != nil {
fmt.Println("Error creating request:", err)
return
}
req.Header.Set("news_api_key", apiKey)
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error sending request:", err)
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response:", err)
return
}
fmt.Println(string(body))
}
Please get in touch with Pramish Luitel if you want to discuss further.
Happy Coding!!