DeviantArtFs 9.0.0-beta2
See the version list below for details.
dotnet add package DeviantArtFs --version 9.0.0-beta2
NuGet\Install-Package DeviantArtFs -Version 9.0.0-beta2
<PackageReference Include="DeviantArtFs" Version="9.0.0-beta2" />
paket add DeviantArtFs --version 9.0.0-beta2
#r "nuget: DeviantArtFs, 9.0.0-beta2"
// Install DeviantArtFs as a Cake Addin #addin nuget:?package=DeviantArtFs&version=9.0.0-beta2&prerelease // Install DeviantArtFs as a Cake Tool #tool nuget:?package=DeviantArtFs&version=9.0.0-beta2&prerelease
DeviantArtFs
A .NET / F# library to interact with the DeviantArt / Sta.sh API.
Design
Each request that can be made to DeviantArt is represented by a function
in one of the modules (static classes) in the DeviantArtFs.Api
namespace.
Each static method takes an IDeviantArtAccessToken
as its first parameter.
Most methods have additional parameters, many of which are discriminated
unions; hopefully this makes it easy to see exactly what your code is doing
and ensures that parameters can't get mixed up.
In some cases, two methods are available for an API call. Functions whose
names begin with Page
will return a single page of results, while the
corresponding Get
function will return an asynchronous sequence which
begins at the offset you specify (see "Interoperability" below). Be careful
not to request too much data or you might hit API usage limits.
Interoperability
In order to maximize ease of use from within F#, the response objects in this
library are .NET records using F# option
types to represent missing fields.
This means that you will need extension methods (see below) to extract a null
value or another placeholder value from these fields.
Version 9.x of this library moves from using F# Async<T>
to using Task<T>
and IAsyncEnumerable<T>
as used in other .NET languages. C# users can use
the extension methods in the NuGet package System.Linq.Async
or consume the
enumerable directly with await foreach
. (As a result of this, I've dropped
support for cancellation tokens in Task<T>
functions; let me know if you'd
like it back.)
The following types are used in response objects:
FSharpOption<T>
: Used to represent fields that may be missing or null on the response object. Extension methods (see below) allow C# and VB.NET users to extract these values by convertingNone
tonull
or to an empty list.FSharpList<T>
: An immutable linked list. ImplementsIReadOnlyList<T>
andIEnumerable<T>
, so other .NET languages can useforeach
, LINQ, or access the list's properties directly.
The following extension methods are provided in the namespace DeviantArtFs.Extensions
:
.OrNull()
: converts an option type to an equivalent nullable type.IsTrue()
: checks whether abool option
type (which might betrue
,false
, orNone
) is true.IsFalse()
: checks whether abool option
type (which might betrue
,false
, orNone
) is false.OrEmpty()
: returns the items in the list, or an empty list if the field isNone
Optional parameters
Optional parameters for object expansion, ext_params
, and mature content
filtering must be included through the token object. Use the interface
IDeviantArtAccessTokenWithOptionalParameters
and include the optional
parameters in the OptionalParameters
property; for example:
public IEnumerable<OptionalParameter> => new OptionalParameter[] {
OptionalParameter.NewExpansion(Expansion.UserProfile),
OptionalParameter.NewExtParam(ExtParam.Gallery),
OptionalParameter.NewMatureContent(true)
}
Deleted deviations and status updates
Deviation
and DeviantArtStatus
objects can represent a deviation or status
update that has been deleted; this is why most of the fields on those two
types are marked optional. Check the is_deleted
field (or IsDeleted
property) before attempting to access any of the other fields.
Known issues
- The profile_pic field in the user.profile expansion is not supported due to circular type definitions. Get it from the full profile object instead.
- The api_session return object is not supported.
Examples
- ExampleConsoleApp: An F# console application that shows some data on the current user's recent (and not-so-recent) submissions, along with some of their Sta.sh info. Reads the access token interactively from standard input.
- ExampleConsoleApp3: An F# console application that submits a picture to Sta.sh and then publishes it to DeviantArt.
- GalleryViewer: A VB.NET app that lets you see the "All" view of someone's gallery and read the descriptions of individual submissions. Uses the Client Credentials grant and stores tokens in a file.
- WebApp: An ASP.NET Core app written in C# that lets you view someone's gallery folders and corresponding submission thumbnails. Uses the Client Credentials grant and stores tokens in a database.
Authentication
See also: https://www.deviantart.com/developers/authentication
The DeviantArtAuth module provides methods to support the Authorization Code grant type (getting tokens from an authorization code and refreshing tokens).
If you are writing a Windows desktop application, the package DeviantArtFs.WinForms package uses Internet Explorer to provide a way to get a code or token from the user.
If you need to store the access token somewhere (such as in a database or
file), you may want to create your own class that implements the
IDeviantArtAccessToken
or IDeviantArtRefreshableAccessToken
interface.
Using the latter will allow DeviantArtFs to automatically refresh the token
and store the new value when it recieves an HTTP 401 response.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. 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. |
-
net6.0
- FSharp.Control.TaskSeq (>= 0.3.0)
- FSharp.Core (>= 7.0.300)
- FSharp.Json (>= 0.4.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on DeviantArtFs:
Package | Downloads |
---|---|
DeviantArtFs.Stash.Marshal
An F#/.NET library to interact with the Sta.sh API and manage state (.NET Standard 2.0) |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
11.0.0 | 80 | 10/28/2024 |
11.0.0-beta2 | 66 | 10/28/2024 |
10.1.0-beta2 | 89 | 10/20/2024 |
10.1.0-beta1 | 73 | 9/21/2024 |
10.0.0 | 122 | 8/8/2024 |
10.0.0-rc1 | 95 | 8/8/2024 |
9.2.1-rc1 | 79 | 8/7/2024 |
9.2.0 | 108 | 6/19/2024 |
9.2.0-beta1 | 94 | 6/19/2024 |
9.1.1 | 120 | 4/27/2024 |
9.1.0-rc1 | 210 | 11/27/2023 |
9.0.0 | 271 | 11/22/2023 |
9.0.0-beta4 | 142 | 5/30/2023 |
9.0.0-beta2 | 108 | 5/28/2023 |
8.0.0 | 463 | 5/30/2021 |
8.0.0-beta4 | 280 | 5/30/2021 |
8.0.0-beta3 | 334 | 5/30/2021 |
8.0.0-beta2 | 235 | 5/30/2021 |
7.0.1 | 402 | 1/11/2021 |
7.0.0 | 381 | 1/9/2021 |
7.0.0-beta1 | 293 | 1/9/2021 |
6.0.2 | 366 | 1/5/2021 |
6.0.1 | 432 | 12/28/2020 |
6.0.0 | 343 | 12/27/2020 |
6.0.0-beta2 | 328 | 12/26/2020 |
6.0.0-beta1 | 320 | 12/26/2020 |
5.0.0 | 517 | 2/11/2020 |
5.0.0-beta1 | 435 | 2/11/2020 |
4.0.0 | 503 | 1/23/2020 |
4.0.0-beta2 | 450 | 1/23/2020 |
4.0.0-beta1 | 459 | 1/22/2020 |
3.0.0 | 552 | 1/17/2020 |
2.2.0 | 555 | 1/6/2020 |
2.1.0 | 531 | 9/9/2019 |
2.0.0-beta3 | 504 | 3/9/2019 |
2.0.0-beta2 | 483 | 3/8/2019 |
2.0.0-beta1 | 478 | 3/6/2019 |
1.1.0-beta1 | 473 | 3/5/2019 |
1.0.0 | 700 | 2/10/2019 |
0.9.0 | 1,349 | 1/29/2019 |
0.8.0 | 692 | 1/28/2019 |
0.7.3 | 714 | 1/22/2019 |
0.7.2 | 693 | 1/22/2019 |
0.7.1 | 1,356 | 1/19/2019 |
0.7.0 | 728 | 1/18/2019 |
0.6.0 | 1,388 | 1/14/2019 |
0.5.0 | 1,358 | 1/11/2019 |
0.4.0 | 1,380 | 1/3/2019 |
0.3.0 | 1,383 | 12/31/2018 |
0.2.0-alpha | 1,182 | 12/27/2018 |
0.1.0-alpha | 618 | 12/21/2018 |