Skip to content

Latest commit

 

History

History
73 lines (53 loc) · 2.26 KB

readme.md

File metadata and controls

73 lines (53 loc) · 2.26 KB

DragonFruit.Data

A lightweight, extensible HTTP/REST framework for .NET

Latest Nuget DragonFruit Discord

Overview

DragonFruit.Data is a HTTP REST client for .NET that is designed to be easy to use and acts as the main web communication system for many DragonFruit products, including internal tools.

Usage/Getting Started

The easiest way to get started is to install the NuGet package, create an ApiClient and start making requests. For more information, see the wiki and the getting started guide.

SteamRequest.cs

using DragonFruit.Data;
using DragonFruit.Data.Requests;

namespace DataExample;

public partial class SteamNewsRequest : ApiRequest
{
    public override string RequestPath => "https://api.steampowered.com/ISteamNews/GetNewsForApp/v0002";

    public SteamNewsRequest(int appId)
    {
        AppId = appId;
    }

    [RequestParameter(ParameterType.Query, "appid")]
    public int AppId { get; set; }

    [RequestParameter(ParameterType.Query, "count")]
    public int? Count { get; set; }

    [RequestParameter(ParameterType.Query, "maxlength")]
    public int? MaxLength { get; set; }

    [RequestParameter(ParameterType.Query, "format")]
    protected string Format => "json";
}

Program.cs

using System.Threading.Tasks;
using DragonFruit.Data;
using DragonFruit.Data.Serializers;

namespace DataExample;

public class Program 
{
    internal static ApiClient Client = new ApiClient<ApiJsonSerializer>
    {
        UserAgent = "DataExample"
    };

    public static async Task Main(string[] args)
    {
        var tf2NewsRequest = new SteamNewsRequest(440);
        var tf2News = await Client.PerformAsync<JsonObject>(tf2NewsRequest);
        
        // tf2News is now a JsonObject that can be manipulated as needed
    }
}

License

The project is licensed under MIT. Refer to license.md for more information.