Skip to content

pnogemane/GNewsAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

GNewsAPI

Deployment Guide: Clone the Repository: Clone the ASP.NET Web Application project from the repository to your local machine. Open Solution in Visual Studio: Open the solution file (.sln) in Visual Studio. Set GNews API Key: Replace "YOUR_API_KEY" with your actual GNews API key in the NewsController.cs file. Build the Solution: Build the solution to ensure there are no compilation errors. Configure Web API Route Prefix: Optionally, you can configure the route prefix for the Web API controller by modifying the RoutePrefix attribute in the NewsController.cs file. Run the Application: Run the application in Visual Studio by pressing F5 or using the Debug menu. Verify that the application runs successfully without any errors. Test the API: Use tools like Postman or simply a web browser to test the API endpoints. Send a GET request to http://localhost:port/api/news to fetch news articles. You can optionally specify a query parameter to fetch news articles on a specific topic. Deploy to Production: Publish the application to your desired hosting environment (e.g., Azure App Service, AWS, etc.) following the deployment guidelines of the respective platform. Functionality Overview: GET /api/news Endpoint: This endpoint is responsible for fetching news articles from the GNews API. It accepts an optional query parameter specifying the topic of news articles to fetch (default is 'technology'). Upon receiving a request, it makes a GET request to the GNews API with the specified query. If the request is successful, it returns the JSON response containing the news articles. If the request fails or encounters an error, it returns an appropriate error response. Error Handling: The API handles errors gracefully and returns meaningful error messages in case of failures. It provides responses with appropriate HTTP status codes such as 200 (OK), 400 (Bad Request), and 500 (Internal Server Error) based on the outcome of the request. API Key Protection: The GNews API key is kept secure and is not exposed directly to clients. It is stored as a constant in the controller and can be replaced easily if needed. Routing and Controller Design: The API follows RESTful routing conventions, with the /api/news endpoint for fetching news articles. The NewsController encapsulates the logic for fetching news articles from the GNews API. Asynchronous Processing: The API utilizes asynchronous processing to handle HTTP requests efficiently, ensuring responsiveness and scalability. Scalability and Performance: The API is designed to be scalable and performant, leveraging asynchronous processing and efficient handling of HTTP requests. By following this deployment guide and understanding the functionality overview, you should be able to deploy and use the GNews API successfully.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages