NicoNico.Net 1.0.0

dotnet add package NicoNico.Net --version 1.0.0
NuGet\Install-Package NicoNico.Net -Version 1.0.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="NicoNico.Net" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NicoNico.Net --version 1.0.0
#r "nuget: NicoNico.Net, 1.0.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 NicoNico.Net as a Cake Addin
#addin nuget:?package=NicoNico.Net&version=1.0.0

// Install NicoNico.Net as a Cake Tool
#tool nuget:?package=NicoNico.Net&version=1.0.0

niconico.net

A C# Library for accessing NicoNico Douga

Nuget Package

Nicovideo is a Japanese video sharing website, similar to Youtube. Users can upload, watch, and comment on videos; both recorded and broadcast live. They don't have a public API persay; Parts of it are public, other parts are not. Some exclusivly use XML, others only JSON, and others give query string options to flip between them. There is a Vita specific API set that is now used on a variety of platforms, such as Wii U and Windows, despite it still having vita specific namespaces and functions.

This library is an attempt to abstract away the insane nature of their API and create a clean library (well, as clean as it can be) that can enable anyone to just get started and make an NicoNico app.

Getting Started

NicoNico.net is a Profile 111 PCL. It should just work in most projects, including WinRT, Xamarin.iOS and Xamarin.Android, and .Net 4.5+. Currently the only dependency is Json.Net.

You can download the Nuget version of the package here

You can also go to your Nuget package manager of choice and search for "niconico.net".

Logging In

In order to make authenticated calls against their system, you must log in. Makes sense right? Logging in is complex however. Unlike most newer APIs the use an OAUTH Rest based system, NicoNico is partially cookie, partially session key based. For the Vita sections of the API, a session key must be appended to the request in order to finish the transaction. So we need to make a few API calls to get all the information we need.

// Login Through Vita API
var authManager = new AuthenticationManager();
var userLoginSession = await authManager.LoginUserThroughV1ApiAsync("email address", "password");
var cookieContainer = authManager.CreateLoginCookieContainer(userLoginSession);

// Reset the authentication manager with the proper cookie container.
authManager = new AuthenticationManager(cookieContainer);
var session = await authManager.StartUserSessionAsync();

userLoginSession contains the user id, session key, and expire time for that session key. We give that to CreateLoginCookieContainer to create the cookie container we will use to make requests with. We then reinitialize the Authentication manager with the cookie container, so now it can use our login credentials. After all that, we can call StartUserSessionAsync to get our actual user session token.

Now you should be logged in.

Getting a Video

Once you have cookies and session key, you are ready to start looking for videos.

var videoManager = new VideoManager(cookieContainer, session.Session);
var watchedList = await videoManager.GetDefListAsync(0, 10);
var videoInfo = watchedList.VideoInfoList.FirstOrDefault();
if (videoInfo != null)
{
  var videoPlay = await videoManager.GetVideoFlvAsync(videoInfo.Video.Id);
  var messages = await videoManager.GetVideoMessageEntityAsync(videoInfo.Thread.Id.ToString(), videoPlay.ApiChannel);
  Console.WriteLine(videoPlay.Url);
}

Here we instantiate the Video Manager with the cookies and session key we got from the above commands. We then get the first 10 recently watched videos, select the first one from the list, and using the videos ID we can get the streaming video URL.

Calling GetVideoMessageEntityAsync lets us get the comments that users have put on top of the video, as well as where they are located. ApiChannel is needed so we know which Nico server to access to retreve them.

TODO

  • Finish mapping currently known API functions
  • Better seperate each part of the API, so users know which apis were accessed from where (Vita, Android, iOS, Web)
  • And probably more I can't think of.
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. 
.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

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
1.0.0 1,096 11/19/2019
0.0.1 1,989 6/18/2015

- Now works with .NET Standard 2.0!