How To Get An EPiServer Page Via the API In EPi7 you can still use the traditional call to the API, however, this way isn't classed as best practice anymore.
var startpage = DataFactory.Instance.Get<PageData>(ContentReference.StartPage);
In EPi 7 the best practice approach is:
var contentLoader = ServiceLocator.Current.GetInstance<IContentLoader>();
var startpage = contentLoader.Get<PageData>(ContentReference.StartPage);
If you are asking yourself why the second snippet is better, I'll explain. In the original version 6 API a singleton pattern was used, called the DataFactory, to access data . This meant developers had to implement a lot of concrete reference all over their code base, which makes unit testing a massive pain in the bum.  As I'm sure most developers know, working towards SOLID principles is a desirable design concept as it allows you to swap out or moc key bits of functionality that can't be unit tested. Working with abstractions rather than concrete implementations helps us, as developers, to create more flexible and testable systems. With the second method we call the abstraction (the interface) and not the concrete implementation. This, in theory, would allow you to inject the interface into your repository and create a testable class. Secondly, the CMS no longer only works with just pages but instead the more general content concept (IContent) has been introduced that allows developers access to a whole range of content. This means that in EPi7 you now have access to objects that may not be page objects anymore. Using the second approach provides more flexibility to cater for different types of content in the future. Below lists some other useful API calls for quick reference How to get all child pages
     var contentLoader = ServiceLocator.Current.GetInstance<IContentLoader>();
    var topLevelPages = contentLoader.GetChildren<PageData>(ContentReference.StartPage);
Return all content items up to, and including, the root page
     var currentBranch = contentLoader.GetAncestors(contentLink).Select(x => x.ContentLink);
Compare if two content items are the same
if (ContentReference.StartPage.CompareToIgnoreWorkID(contentLink))
Do you know any other useful Epi API calls ? Leave your most used snippets in the comment section below