reduce the amount of data returned from api call?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jamie
    Senior Member
    • Aug 2025
    • 185

    #1

    reduce the amount of data returned from api call?

    i need to drastically reduce the amount of data returned by the entity lookup api call its returning every bit of data when i am only needing a small fraction of what's being returned

    Here is an example of the api call



    And to be clear, i don't want to reduce the amount of records, just the data in each record, i really only need what i am displaying and the id, not every single bit of data in the record that the table is now over 100 columns, you can imagine the delays for something i can't display

    yuri any thoughts on how to do this in an easy upgrade-friendly way?
  • emillod
    Active Community Member
    • Apr 2017
    • 1541

    #2
    You can use scope param to specify which fields should be returned

    Comment

    • jamie
      Senior Member
      • Aug 2025
      • 185

      #3
      Originally posted by emillod
      You can use the scope param to specify which fields should be returned
      This is an internal espo call for when it's looking up a linked records to insert the id into the current record, what i would call a foreign key lookup, so is this something i can control inside entity defs?

      Comment

      • a.slyzhko
        Senior Member
        • Oct 2023
        • 121

        #4
        You need to specify query param 'attributeSelect' with a list of needed attributes separated by comma. No attributeSelect means select all attributes

        Comment

        • jamie
          Senior Member
          • Aug 2025
          • 185

          #5
          Originally posted by a.slyzhko
          You need to specify query param 'attributeSelect' with a list of needed attributes separated by comma. No attributeSelect means select all attributes
          yeah that sounds like it might be the one i'd set that in entity defs? in the links section?

          Code:
          "workRecords": {
          "type": "hasMany",
          "relationName": "cServiceSpareWorkRecord",
          "foreign": "cServiceSpares",
          "entity": "WorkRecord",
          "audited": true,
          "isCustom": true
          },

          Comment

          • jamie
            Senior Member
            • Aug 2025
            • 185

            #6
            The main issue is that when we have a one-to-one relationship, it tends to bring in an extra 20,000 PLUS records. There are situations where one-to-one relationships are necessary, but when linking one entity to another, we really don’t need to pull in every single piece of data from the foreign record—only the data required to establish the link for the current record.

            Personally, this feels like a bug.

            Unless yuri knows a way to limit the number of records that the entity link lookup pulls into the front end?

            Comment

            • yuri
              EspoCRM product developer
              • Mar 2014
              • 9540

              #7
              > The main issue is that when we have a one-to-one relationship, it tends to bring in an extra 20,000 PLUS records.

              It's rather wrong definitions in your customization.

              The initial question is clearly and correctly answered in the post #4.
              If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

              Comment

              • yuri
                EspoCRM product developer
                • Mar 2014
                • 9540

                #8
                Places in the documentation where the 'select' parameter (or its alias 'attributeSelect ') is covered:

                1: https://docs.espocrm.com/development/api/crud/#list
                2: https://docs.espocrm.com/development...params/#select
                3: https://docs.espocrm.com/api/#/paths/Account/get
                If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

                Comment

                • jamie
                  Senior Member
                  • Aug 2025
                  • 185

                  #9
                  Originally posted by yuri
                  Places in the documentation where the 'select' parameter (or its alias 'attributeSelect ') is covered:

                  1: https://docs.espocrm.com/development/api/crud/#list
                  2: https://docs.espocrm.com/development...params/#select
                  3: https://docs.espocrm.com/api/#/paths/Account/get
                  So, what one of these do i need to do to fix my problem? What do I need to add to what file?

                  i need to specify exactly what gets returned when i try to link one entity to another

                  Comment

                  • yuri
                    EspoCRM product developer
                    • Mar 2014
                    • 9540

                    #10
                    Originally posted by a.slyzhko
                    You need to specify query param 'attributeSelect' with a list of needed attributes separated by comma. No attributeSelect means select all attributes
                    Query parameter. Query parameter is parameter specified in the URL, the way you already specified some (e.g. maxSize). a.slyzhko clearly stated what to do. Specify the attributes you need in query parameters, the attributes are separated by comma. Attributes correspond to the field names. It's all covered in the docs.
                    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

                    Comment

                    Working...