I am looking for SP Rest api to return all Terms and its GUID under specific termsets in my SP online Site and in my On Prem site. Is it possible?

if not Rest API, is it possible to pull them using client Context?

5 Answers 5


You could just use the pnp cmdlet Get-PnPTerm to get all Terms and its GUID under specific termsets. It's very easy.

Read here for more:


  • I have access to a Microsoft Teams site collection as an Owner, and therefore can add terms to a term store etc and utilise them in lists and libraries, but i do not have the permissions required to use powershell etc to export terms. Is there another way to do it with with standard Owner permissions. This is in corporate environment where i can't just install the tools i need to do the required job, everything has to go through central IT department etc. Commented Jul 14, 2021 at 6:57

The rest 2.1 API supports CRUD operations on the TermStore. There is an useful write-up of accessing the terms located here: https://www.c-sharpcorner.com/blogs/sharepoint-managed-metadata-services-rest-api

List Terms in Term Set

Endpoint : Endpoint : https://testinglala.sharepoint.com/_api/v2.1/termStore/groups/122d92ab-d7a8-479f-9888-8d4421f8218f/sets/8ed8c9ea-7052-4c1d-a4d7-b9c10bffea6f/terms      
Method : GET    
Headers : {"Content-Type": "application/json",  
           "Authorization": "Bearer <Bearer Token>"} 

List Terms Nested Under Term in Term Set

Endpoint : https://testinglala.sharepoint.com/_api/v2.1/termStore/groups/122d92ab-d7a8-479f-9888-8d4421f8218f/sets/8ed8c9ea-7052-4c1d-a4d7-b9c10bffea6f/terms/12345678-1234-1234-1234-123456789012/children      
Method : GET      
Headers : {"Content-Type": "application/json",    
           "Authorization": "Bearer <Bearer Token>"}

Not sure if this can be done with REST but it's certainly possible with Client Context. The process should be the same for On Prem or Online.

Also, if you just want to get this information for reference, PowerShell is probably a better way to get it. The PowerShell cmdlets for SP Taxonomy make it easy to export all term labels and GUIDs to a CSV file.

Below is some JS that will print out the name and GUID for all terms in the given term set(s). This must be run from a page that has access to the SP object (i.e. a page in SharePoint).

var termSetArray = ["ce7f5d96-f7eb-45c3-83ef-062b6bdbf722"];

  SP.SOD.executeFunc("sp.js", "SP.ClientContext", function () {
    SP.SOD.registerSod("sp.taxonomy.js", SP.Utilities.Utility.getLayoutsPageUrl("sp.taxonomy.js"));
    SP.SOD.executeFunc("sp.taxonomy.js", "SP.Taxonomy.TaxonomySession",
      function () {
        // Get Context and load terms
        var ctx = SP.ClientContext.get_current();
        var taxSession = SP.Taxonomy.TaxonomySession.getTaxonomySession(ctx);
        var termStore = taxSession.getDefaultSiteCollectionTermStore();
        var termSet = termStore.getTermSet(termSetId);
        var terms = termSet.getAllTerms();

        // Iterate through Terms
        ctx.executeQueryAsync(function () {
          var termEnum = terms.getEnumerator()
          while (termEnum.moveNext()) {
            var currentTerm = termEnum.get_current();
            var name = currentTerm.get_name();
            var id = currentTerm.get_id().toString();
            console.log('Term: ', name, id);
        }, function () { console.log('error') });


A quick Google search for "sharepoint rest taxonomy" turned up the article here that gives an example of using an internal REST endpoint to get terms from a term set. To quote that article:

Below is quite a simple approach ( which Microsoft hasn’t documented to use for external applications ) to query term store using REST API.


Its for you to take a decision to use it or not.

Its a simple POST request to one of the internal service (which will probably not be taken out by MS because they happen to use it internally). Below is sample code to get all terms from a term set.

and the code example given is:

    url: "https://<your-tenant>.sharepoint.com/_vti_bin/TaxonomyInternalService.json/GetChildTermsInTermSetWithPaging",
    type: "POST",
    headers: {
        "accept": "application/json;odata.metadata=minimal",
        "content-type": "application/json;charset=utf-8",
        "odata-version": "4.0",
        "X-RequestDigest": $("#__REQUESTDIGEST").val()
    data: JSON.stringify({
        lcid: 1033,
        sspId: "guid-here", //Term store ID
        guid: "guid-here", //Term set ID
        includeDeprecated: false,
        pageLimit: 1000,
        pagingForward: false,
        includeCurrentChild: false,
        currentChildId: "00000000–0000–0000–0000–000000000000",
        webId: "00000000–0000–0000–0000–000000000000",
        listId: "00000000–0000–0000–0000–000000000000"
    success: function (data) {
        console.log("Rejoice, for now you can use REST", data);

Now, I haven't tried it, so YMMV. The article also links to this MS documentation page which gives other method names / endpoints you might be able to use.


CSOM and AJAX calls are not recommended within SPFx apps - as these are older methods so will probably be depreciated.

I know the post replies are from two years ago, but perhaps the forum supervisors need to clean up out-of-date posts, so incorrect information is not still available. Like the two links provided by Dylan Cristy to no longer supported methods.

The _api/v2.1/termStore REST endpoint is the recommended method to get termstore metadata and can be used in No Framework or React JS framework apps.

  • perhaps the forum supervisors need to clean up out-of-date posts, so incorrect information is not still available - we have moderator flags for that, or you could leave a comment once you have 50 reputation
    – Glorfindel
    Commented Sep 6, 2022 at 12:37
  • Comments like these should be removed - there are still plenty of OnPremise SharePoint installations not using SPFx. It's good to add updates how it is done Online in 2022, but OnPremise (even in SP2019) SPFx is definitely not the #1 choice due to e.g. Node.js v8 and pnp.js limitations - and most likely won't be the #1 choice in SharePoint Subscription edition either if Node.js and pnp.js continues to lack behind Online version. Commented Nov 24, 2022 at 6:23
  • All but SP 2019 OnPremise are now at end of life. So you shouldn't be using them. SP 2019 OnPrem will be depreciated by 2026. So really you should move to SP Online and stop using out-of-date systems that pose serious security risks to businesses. So I agree with #Glorfindel that legacy methods should be removed and we should move forwards with the new methods. SP OnPremise is dead.
    – Jason
    Commented Mar 7, 2023 at 23:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.