BuzzSpire.Nexar 2024.1012.0

Prefix Reserved
dotnet add package BuzzSpire.Nexar --version 2024.1012.0                
NuGet\Install-Package BuzzSpire.Nexar -Version 2024.1012.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BuzzSpire.Nexar" Version="2024.1012.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BuzzSpire.Nexar --version 2024.1012.0                
#r "nuget: BuzzSpire.Nexar, 2024.1012.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install BuzzSpire.Nexar as a Cake Addin
#addin nuget:?package=BuzzSpire.Nexar&version=2024.1012.0

// Install BuzzSpire.Nexar as a Cake Tool
#tool nuget:?package=BuzzSpire.Nexar&version=2024.1012.0                

Nexar

Nexar is a powerful and user-friendly C# class designed for seamless communication with web APIs. With Nexar, sending and receiving HTTP requests has never been easier. Whether you need to perform simple GET requests or more complex POST operations, Nexar provides a clean and efficient interface to interact with web services.

Features

  • Simple API: Easy-to-use methods for all major HTTP verbs (GET, POST, PUT, DELETE, PATCH, HEAD).
  • Asynchronous Operations: Built-in support for asynchronous requests, ensuring your applications remain responsive.
  • Customizable Headers: Easily manage request headers for enhanced control over your API interactions.
  • Error Handling: Robust error handling to manage exceptions and keep your applications running smoothly.
  • Resource Management: Automatically handles resource disposal to prevent memory leaks.

Example Usage

Here’s a quick example to demonstrate how to use the Nexar class to send a GET request:

var nexar = new Nexar();

var headers = new Dictionary<string, string>
{
    { "Accept", "application/json" },
};

try
{
    var response = await nexar.GetAsync("https://api.example.com", headers);
    Console.WriteLine(response);
}
catch (Exception ex)
{
    Console.WriteLine($"An error occurred: {ex.Message}");
}
finally
{
    nexar.Dispose();
}

Here’s a quick example to demonstrate how to use the Nexar class to send a POST request:

var nexar = new Nexar();

var headers = new Dictionary<string, string>
{
    { "Accept", "application/json" },
};

try
{
     var body = new
        {
            id = 21,
            title = "test product",
            price = 13.5,
            description = "lorem ipsum set",
            image = "https://i.pravatar.cc",
            category = "electronic"
        };

        var response =
            await _nexar.PostAsync("https://api.example.com/products", headers, body);
          Console.WriteLine(response);
}
catch (Exception ex)
{
    Console.WriteLine($"An error occurred: {ex.Message}");
}
finally
{
    nexar.Dispose();
}

In this example, an instance of the Nexar class is created, headers are defined, and a GET request is sent to https://api.example.com. The response is printed to the console, while errors are gracefully handled.

Available Methods

Nexar provides the following methods for various HTTP operations:

  • GetAsync(string url, Dictionary<string, string> headers): Sends a GET request.
  • PostAsync(string url, Dictionary<string, string> headers, string body): Sends a POST request with a body.
  • PutAsync(string url, Dictionary<string, string> headers, string body): Sends a PUT request with a body.
  • DeleteAsync(string url, Dictionary<string, string> headers): Sends a DELETE request.
  • PatchAsync(string url, Dictionary<string, string> headers, string body): Sends a PATCH request with a body.
  • HeadAsync(string url, Dictionary<string, string> headers): Sends a HEAD request.

Each method takes a URL and a dictionary of headers, while the PostAsync, PutAsync, and PatchAsync methods also accept a request body.

Installation

To add Nexar to your project, you can clone the repository or download the latest release. Ensure you have .NET installed and referenced in your project.

git clone https://github.com/BuzzSpire/Nexar.git

Contributing

Contributions are welcome! If you have suggestions or improvements, please open an issue or submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Support

If you encounter any issues or have questions about using Nexar, please open an issue on GitHub, and I’ll be happy to help!


Enhance your C# applications with the power of Nexar and streamline your API interactions today!

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2024.1012.0 88 10/12/2024
1.0.0 91 10/8/2024

## What's Changed
* start 🎉 by @tw4 in https://github.com/BuzzSpire/Nexar/pull/1
* refactor: folder structer by @tw4 in https://github.com/BuzzSpire/Nexar/pull/2
* Update README.md by @tw4 in https://github.com/BuzzSpire/Nexar/pull/3
* feat: get async simple test by @tw4 in https://github.com/BuzzSpire/Nexar/pull/4
* feat: add nuget package by @tw4 in https://github.com/BuzzSpire/Nexar/pull/5
* Delete .idea/.idea.Nexar /.idea directory by @tw4 in https://github.com/BuzzSpire/Nexar/pull/6
* fix: test api is not work by @tw4 in https://github.com/BuzzSpire/Nexar/pull/7
* fix: async post request body by @tw4 in https://github.com/BuzzSpire/Nexar/pull/8
* fix: put, delete. patch by @tw4 in https://github.com/BuzzSpire/Nexar/pull/9
* updata: docs by @tw4 in https://github.com/BuzzSpire/Nexar/pull/10

## New Contributors
* @tw4 made their first contribution in https://github.com/BuzzSpire/Nexar/pull/1

**Full Changelog**: https://github.com/BuzzSpire/Nexar/commits/2024.1012.0