RESTween.Core
1.7.10
dotnet add package RESTween.Core --version 1.7.10
NuGet\Install-Package RESTween.Core -Version 1.7.10
<PackageReference Include="RESTween.Core" Version="1.7.10" />
<PackageVersion Include="RESTween.Core" Version="1.7.10" />
<PackageReference Include="RESTween.Core" />
paket add RESTween.Core --version 1.7.10
#r "nuget: RESTween.Core, 1.7.10"
#:package RESTween.Core@1.7.10
#addin nuget:?package=RESTween.Core&version=1.7.10
#tool nuget:?package=RESTween.Core&version=1.7.10
RESTween.Core
RESTween.Core contains the shared contract attributes used by the RESTween client and server packages.
Install this package when you want to define REST API interfaces in a shared assembly without taking a dependency on the client runtime (RESTween) or the server source generator (RESTween.Server).
What This Package Provides
- HTTP method attributes:
[Get],[Post],[Put],[Delete]. - Parameter binding attributes:
[Route],[Query],[Body],[Header]. - Query collection formatting through
CollectionFormat. - A small
netstandard2.0contract assembly that can be referenced by shared DTO or contract projects.
Install
dotnet add package RESTween.Core
Most users do not need to install this package directly. It is installed automatically when you install RESTween or RESTween.Server.
Use it directly when you have a separate contracts project:
MyApp.Contracts -> RESTween.Core
MyApp.Client -> RESTween
MyApp.Api -> RESTween.Server
Define Shared API Contracts
using RESTween.Attributes;
public interface IUserApi
{
[Get("/users/{id}")]
Task<UserDto> GetUserAsync([Route] int id);
[Get("/users")]
Task<IReadOnlyList<UserDto>> SearchUsersAsync([Query] UserSearchQuery query);
[Post("/users")]
Task<UserDto> CreateUserAsync([Body] CreateUserDto dto);
[Put("/users/{id}")]
Task<UserDto> UpdateUserAsync([Route] int id, [Body] UpdateUserDto dto);
[Delete("/users/{id}")]
Task DeleteUserAsync([Route] int id);
}
The same interface can then be used:
- On the client side by
RESTweento create HTTP proxy clients. - On the server side by
RESTween.Serverto generate ASP.NET Core controllers. - In shared libraries to keep API contracts and DTOs in one place.
HTTP Method Attributes
Use these attributes on interface methods:
[Get("/users/{id}")]
[Post("/users")]
[Put("/users/{id}")]
[Delete("/users/{id}")]
Each method attribute stores the URL template. The client package turns it into an outgoing HttpRequestMessage; the server package turns it into ASP.NET Core routing attributes.
Parameter Binding Attributes
Route
[Get("/users/{id}")]
Task<UserDto> GetUserAsync([Route] int id);
You can also provide an explicit route placeholder name:
[Get("/users/{userId}")]
Task<UserDto> GetUserAsync([Route("userId")] int id);
Query
[Get("/users")]
Task<IReadOnlyList<UserDto>> SearchAsync([Query("term")] string searchTerm);
Collections can use the default format or CollectionFormat.Multi:
[Get("/users")]
Task<IReadOnlyList<UserDto>> SearchAsync(
[Query("role", CollectionFormat.Multi)] string[] roles);
CollectionFormat.Multi is used by the client package to emit repeated name[] query keys.
Body
[Post("/users")]
Task<UserDto> CreateUserAsync([Body] CreateUserDto dto);
The client package serializes body values as JSON. The server package maps them to ASP.NET Core [FromBody].
Header
[Get("/profile")]
Task<ProfileDto> GetProfileAsync([Header("Authorization")] string authorization);
The client package writes parameter values into request headers. The server package maps them to ASP.NET Core [FromHeader].
Client-Only Attributes
Some attributes are intentionally not part of RESTween.Core because they describe client request-building behavior rather than shared HTTP contracts.
These attributes live in the RESTween client package:
[Headers]for static request headers.[Multipart]formultipart/form-dataclient requests.[Cache]for metadata inspected by custom client handlers.[RateLimit]for metadata inspected by custom client handlers.
They keep the same namespace, RESTween.Attributes, so client code can still use the same using directive after installing RESTween.
What This Package Does Not Do
RESTween.Core does not:
- Send HTTP requests.
- Register DI services.
- Generate ASP.NET Core controllers.
- Serialize request or response bodies.
- Provide client-only request-building metadata such as
[Headers],[Multipart],[Cache], or[RateLimit].
For HTTP clients, install RESTween.
For server controller generation, install RESTween.Server.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on RESTween.Core:
| Package | Downloads |
|---|---|
|
RESTween
RESTween is a lightweight dynamic REST API client for .NET. It creates runtime HTTP clients from interface contracts, supports GET, POST, PUT, DELETE, route/query/header/body/multipart binding, custom request handlers, and an extensible request-building pipeline. |
|
|
RESTween.Server
Runtime ASP.NET Core controller generation for RESTween API interfaces using Reflection.Emit. |
GitHub repositories
This package is not used by any popular GitHub repositories.