HTTPS SSH
# Revit Server API Library

- [Bitbucket](https://bitbucket.org/somddg/revitserverapilib)
- [NuGet](https://www.nuget.org/packages/RevitServerAPILib/)

A .NET Class library for accessing and manipulating Revit Server through its REST API.


## Usage

The REST API of a Revit Server is accessed by creating an instance of the `RevitServer` class.


    RevitServer server = new RevitServer("HOSTNAME",2015);

Methods on this class can be used to query information from and manipulate the models on the target server.

    //Create a new RevitServer instance
    RevitServerAPILib.RevitServer server = new RevitServerAPILib.RevitServer("HOSTNAME", 2015);
    
    //Get properties of the server
    var properties = server.GetServerProperties();
    
    //Rename a model
    server.Rename(@"Folder\File.rvt","NewFileName.rvt");
    
    //Lock a model
    server.Lock(@"Folder\File.rvt");
    
    //List the history of a model
    var history = server.GetModelHistory(@"Folders\File.rvt");
    foreach(var item in history.Items.OrderByDescending(i=>i.VersionNumber))
    {
         Console.WriteLine("{0}\t{1}\t{2}",item.Date.ToString(),item.User, item.Comment);
    }
    
    //List the models contained by a folder
    var folderContents = server.GetFolderContents(@"Folder\SubFolder");
    
    foreach (var model in folderContents.Models)
    {
        Console.WriteLine("{0}\t{1}\t{2}",model.Name,model.LockState.ToString(),model.ModelSize.ToString());
    }