olspy 2.2.2

dotnet add package olspy --version 2.2.2
                    
NuGet\Install-Package olspy -Version 2.2.2
                    
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="olspy" Version="2.2.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="olspy" Version="2.2.2" />
                    
Directory.Packages.props
<PackageReference Include="olspy" />
                    
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 olspy --version 2.2.2
                    
#r "nuget: olspy, 2.2.2"
                    
#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.
#:package olspy@2.2.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=olspy&version=2.2.2
                    
Install as a Cake Addin
#tool nuget:?package=olspy&version=2.2.2
                    
Install as a Cake Tool

Olspy

A basic read-only API for Overleaf

What it can do

  • Connect to any Overleaf instance that is accessible through the browser
  • Read a project's file structure
  • Read the contents of documents
  • Request compilations
  • Read edit history

What is can't do

  • List a user's projects
  • Make edits in a document
  • Observe real-time edits to a document

Usage

First, open a project using one of the overloads of Olspy.Project.Open():

// join via a normal share link
var project = await Olspy.Project.Open(new Uri("https://my-overleaf-instance.com/SHARE-URL-HERE>"));
// join via project ID and session token
var project = await Olspy.Project.Open(new Uri("https://my-overleaf-instance.com/base-url"), "PROJECT ID HERE", "SESSION TOKEN COOKIE HERE");
// join via project ID and user credentials
var project = await Olspy.Project.Open(new Uri("https://my-overleaf-instance.com/base-url"), "PROJECT ID HERE", "YOUR@EMAIL.HERE", "YOUR PASSWORD HERE");

Project Information and File Structure

To get project information such as its name, the file structure and the contents of documents, either open a project session like this:

async using(var session = await project.Join())
{
	// contains general project info, including its file tree
	var info = await session.GetProjectInfo();
	// info.project holds miscellaneous project information
	var mainFile = info.project.RootDocID;
	// gets the lines of an editable document
	var lines = await session.GetDocumentByID(mainFile);
}

Or use equivalent methods on project that open temporary sessions automatically:

var info = await project.GetProjectInfo();
// info.project holds miscellaneous project information 
var mainFile = info.project.RootDocID;
// gets the lines of an editable document
var lines = await project.GetDocumentByID(mainFile);

Compiling

To compile a document, use the Project.Compile() method like this

// you can also specify different main files, draft mode, etc.
var compilation = await project.Compile();

The return value specifies the created files:

// First, find an output file ID
var aux = compilation.OutputFiles.First(f => f.Path.EndsWith(".aux"));
// Then retrieve it via the project
var auxContent = await project.GetOutFile(aux);
// GetOutFile() returns a HttpContent
var auxString = await auxContent.ReadAsStringAsync();

To check for success (defined as producing a PDF, even if there may have been non-fatal compile errors) use IsSuccess():

if(compilation.IsSuccess(out var pdf))
{
	// pdf is the produced PDF file
	var pdfContent = await project.GetOutFile(pdf);

	using(var f = File.Create("compiled.pdf"))
		await pdfContent.CopyToAsync(f);
}
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

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
2.2.2 143 10/8/2024
2.2.1 187 4/17/2024
2.2.0 155 2/25/2024
2.1.3 146 2/24/2024
2.1.2 152 2/15/2024
2.1.1 160 2/15/2024
2.1.0 164 2/12/2024
2.0.0 162 2/1/2024