DeviantArtFs 6.0.0-beta1

This is a prerelease version of DeviantArtFs.
There is a newer version of this package available.
See the version list below for details.
dotnet add package DeviantArtFs --version 6.0.0-beta1
                    
NuGet\Install-Package DeviantArtFs -Version 6.0.0-beta1
                    
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="DeviantArtFs" Version="6.0.0-beta1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DeviantArtFs" Version="6.0.0-beta1" />
                    
Directory.Packages.props
<PackageReference Include="DeviantArtFs" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DeviantArtFs --version 6.0.0-beta1
                    
#r "nuget: DeviantArtFs, 6.0.0-beta1"
                    
#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.
#addin nuget:?package=DeviantArtFs&version=6.0.0-beta1&prerelease
                    
Install DeviantArtFs as a Cake Addin
#tool nuget:?package=DeviantArtFs&version=6.0.0-beta1&prerelease
                    
Install DeviantArtFs as a Cake Tool

DeviantArtFs

A .NET / F# library to interact with the DeviantArt / Sta.sh API.

If you're using this library in a .NET Framework project and it doesn't run, make sure that the dependencies (e.g. FSharp.Core, FSharp.Json, FSharp.Control.AsyncSeq) are installed via NuGet.

Notes

Each request that can be made to DeviantArt is represented by a module somewhere in the DeviantArtFs.Api namespace. These modules have static methods that take one or more parameters:

  • token (an object that implements the IDeviantArtAccessToken interface and provides the library with the API credentials)
  • common (allows user object expansion and mature content filtering; DeviantArtCommonParams.Default will hide mature content and avoid all user object expansion)
  • A parameter specific to the request (if any)
  • paging / cursor / offset (for endpoints that ask the user to request a particular range of results; paging will be a DeviantArtPagingParams record, which contains an offset and an optional limit)
    • To request the maximum page size that DeviantArt allows for a particular request, use int.MaxValue as the limit

The main method is usually named AsyncExecute and returns an async workflow, the result of which is an F# record type that lines up with the original JSON. An ExecuteAsync method is also available that returns a .NET Task instead.

For endpoints that allow paging, ToAsyncSeq and ToArrayAsync methods will be available as well; when using these, DeviantArtFs will perform multiple API calls, asking for the maximum amount of results in each. Be careful not to request too much data or you might hit API usage limits.

Optional types

Many objects in the DeviantArt API have optional fields, which are difficult to represent in languages such as F# that expect a fixed schema. DeviantArtFs represents these optional fields with F# option types.

The library provides extension methods in the namespace DeviantArtFs.Extensions for dealing with option types from outside F#:

public string GetTitleCarefully(Deviation d) {
    return d.title.ToObj() ?? "Could not find title!";
}

public string GetTitleRecklessly(Deviation d) {
    return d.title.Value; // throws an exception if field is None
}

public IEnumerable<DeviationPreview> GetThumbnails(Deviation d) {
    return d.thumbs.OrEmpty();
}

public bool CheckIfFavorited(Deviation d) {
    return d.is_favourited.IsTrue();
}

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.

Partial updates

Stash.Update and User.ProfileUpdate allow you to choose which fields to update on the object. DeviantArtFs uses discriminated unions to represent these updates:

await Requests.User.ProfileUpdate.ExecuteAsync(token, new[] {
    ProfileUpdateField.NewArtistLevel(ArtistLevel.Student),
    ProfileUpdateField.NewWebsite("https://www.example.com")
});

await Requests.Stash.Update.ExecuteAsync(token, 12345678L, new[] {
    UpdateField.NewTitle("new stack title"),
    UpdateField.ClearDescription
});

Note that DeviantArt allows a null value for the "description" field on a Sta.sh stack, and this is represented by its own union case.

Known issues

  • The following fields in the deviation object are not supported:
    • challenge
    • challenge_entry
    • motion_book
  • 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.
  • Some of the newer fields on the deviation object (like premium_folder_data or text_content) are not currently supported.
  • The api_session return object is ignored.

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.
  • 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 2.1 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

Both Authorization Code (recommended) and Implicit grant types are supported. 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 using either grant type.

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, IDeviantArtRefreshToken, or IDeviantArtAutomaticRefreshToken interface. Using the latter will allow DeviantArtFs to automatically refresh the token and store the new value when it recieves an HTTP 401 response. (An InvalidRefreshTokenException is thrown if the token cannot be refreshed.)

Product 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. 
.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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 123 10/28/2024
11.0.0-beta2 85 10/28/2024
10.1.0-beta2 99 10/20/2024
10.1.0-beta1 87 9/21/2024
10.0.0 141 8/8/2024
10.0.0-rc1 107 8/8/2024
9.2.1-rc1 92 8/7/2024
9.2.0 130 6/19/2024
9.2.0-beta1 105 6/19/2024
9.1.1 135 4/27/2024
9.1.0-rc1 217 11/27/2023
9.0.0 279 11/22/2023
9.0.0-beta4 157 5/30/2023
9.0.0-beta2 118 5/28/2023
8.0.0 488 5/30/2021
8.0.0-beta4 301 5/30/2021
8.0.0-beta3 357 5/30/2021
8.0.0-beta2 258 5/30/2021
7.0.1 435 1/11/2021
7.0.0 411 1/9/2021
7.0.0-beta1 319 1/9/2021
6.0.2 403 1/5/2021
6.0.1 464 12/28/2020
6.0.0 374 12/27/2020
6.0.0-beta2 356 12/26/2020
6.0.0-beta1 349 12/26/2020
5.0.0 550 2/11/2020
5.0.0-beta1 465 2/11/2020
4.0.0 537 1/23/2020
4.0.0-beta2 482 1/23/2020
4.0.0-beta1 491 1/22/2020
3.0.0 586 1/17/2020
2.2.0 590 1/6/2020
2.1.0 567 9/9/2019
2.0.0-beta3 537 3/9/2019
2.0.0-beta2 515 3/8/2019
2.0.0-beta1 512 3/6/2019
1.1.0-beta1 506 3/5/2019
1.0.0 744 2/10/2019
0.9.0 1,395 1/29/2019
0.8.0 728 1/28/2019
0.7.3 751 1/22/2019
0.7.2 732 1/22/2019
0.7.1 1,394 1/19/2019
0.7.0 767 1/18/2019
0.6.0 1,429 1/14/2019
0.5.0 1,395 1/11/2019
0.4.0 1,420 1/3/2019
0.3.0 1,422 12/31/2018
0.2.0-alpha 1,215 12/27/2018
0.1.0-alpha 652 12/21/2018

6.0.0: Updates for new version of DeviantArt API; refactoring for cleaner code